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//pku1579 #include<iostream> using namespace std; int w[25][25][25]; void set() { int i,j,k; for(i=0;i<=20;i++) for(j=0;j<=20;j++) w[i][j][0]=w[i][0][j]=w[0][i][j]=1; for(i=1;i<=20;i++) for(j=1;j<=20;j++) for(k=1;k<=20;k++) { if(i<j&&j<k) w[i][j][k]=w[i][j][k-1]+ w[i][j-1][k-1]-w[i][j-1][k]; else w[i][j][k]=w[i-1][j][k]+ w[i-1][j-1][k]+w[i-1][j][k-1]-w[i-1][j-1][k-1]; } } int main() { int a,b,c; set(); while(scanf("%d %d %d",&a,&b,&c)!=EOF) { if(a==-1&&b==-1&&c==-1) break; printf("w(%d %d %d) = ",a,b,c); if(a<=0||b<=0||c<=0) { printf("%d\n",w[0][0][0]); } else if(a>20||b>20||c>20) { printf("%d\n",w[20][20][20]); } else printf("%d\n",w[a][b][c]); } system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator