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 |
为什么会WA?看了好几遍了。。应该没错了呀。。#include <stdio.h> int dp[21][21][21]; int main(){ int a,b,c,i,j,k,m,n,p; for(i=0;i<=21;i++) for(j=0;j<=21;j++) { dp[0][i][j]=1; dp[i][0][j]=1; dp[i][j][0]=1; } while(scanf("%d%d%d",&a,&b,&c)&&(a!=-1||b!=-1||c!=-1)){ m=a; n=b; p=c; if(m<=0||n<=0||p<=0) { m=0; n=0; p=0; } else if(m>20||n>20||p>20) { m=20; n=20; p=20; } for(i=1;i<=m;i++) for(j=1;j<=n;j++) for(k=1;k<=p;k++){ if(i<j&&j<k) dp[i][j][k]=dp[i][j][k-1]+dp[i][j-1][k-1]-dp[i][j-1][k]; else dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k]+dp[i-1][j][k-1]-dp[i-1][j-1][k-1]; } printf("w(%d, %d, %d) = %d\n",a,b,c,dp[m][n][p]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator