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