//Pascal‘s Travels #include<stdio.h> #include<string.h> int main(){ int n,i,j,t; long long dp[35][35]; char b[35][35]; while(scanf("%d",&n)!=EOF&&n!=-1){ getchar(); for(i=0;i<n;i++){ gets(b[i]); } memset(dp,0,sizeof(dp)); dp[0][0]=1; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(dp[i][j]){ if(b[i][j]-‘0‘){ t=b[i][j]-‘0‘+i; if(t<=n) dp[t][j]+=dp[i][j]; t=b[i][j]-‘0‘+j; if(t<=n) dp[i][t]+=dp[i][j]; } } } } printf("%lld\n",dp[n-1][n-1]); } return 0; }
本文出自 “apple” 博客,请务必保留此出处http://22222222222.blog.51cto.com/9928498/1715204
原文:http://22222222222.blog.51cto.com/9928498/1715204