Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:为什么我还是WA 啊?请高手帮帮忙看看(附程序)In Reply To:注意的是,结果用__int64存储才不会溢出。 Posted by:ACM30021 at 2005-11-09 21:48:50 #include <stdio.h> #include <iostream.h> #define maxn 35 char a[maxn][maxn]; _int64 f[maxn][maxn]; int n; int main() { int i ,j ,k , m; while(cin>>n &&n!=-1) { for(i=1 ; i<=n ; i++) for(j=1 ;j<=n ;j++) { cin >> a[i][j]; f[i][j]=0; } f[1][1] =1; for(i=1 ; i<=n ;i++) { for(j=1 ; j<=n ;j++) { for(k =1 ; k<=i-1 ;k++) if(i-k==a[k][j]-'0') f[i][j] += f[k][j]; for(m =1 ; m<=j-1 ;m++) if(j-m == a[i][m]-'0') f[i][j] += f[i][m]; } } printf("%lld\n" , f[n][n]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator