标签:style blog http color os io for art
1 //Accepted 176 KB 0 ms 2 //预处理出来0--20的部分 3 //dp 4 //其中用到-1的值 5 //把所有的点左移一下 6 #include <cstdio> 7 #include <cstring> 8 #include <iostream> 9 using namespace std; 10 const int imax_n = 22; 11 int dp[imax_n][imax_n][imax_n]; 12 int n; 13 void Dp() 14 { 15 memset(dp,0,sizeof(dp)); 16 for (int i=0;i<imax_n;i++) 17 for (int j=0;j<imax_n;j++) 18 for (int k=0;k<=1;k++) 19 dp[i][j][k]=1; 20 for (int i=0;i<=1;i++) 21 for (int j=0;j<imax_n;j++) 22 for (int k=0;k<imax_n;k++) 23 dp[i][j][k]=1; 24 for (int i=0;i<imax_n;i++) 25 for (int j=0;j<=1;j++) 26 for (int k=0;k<imax_n;k++) 27 dp[i][j][k]=1; 28 for (int i=2;i<imax_n;i++) 29 { 30 for (int j=2;j<imax_n;j++) 31 { 32 for (int k=2;k<imax_n;k++) 33 { 34 if (i<j && j<k) 35 dp[i][j][k]=dp[i][j][k-1]+dp[i][j-1][k-1]-dp[i][j-1][k]; 36 else 37 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]; 38 } 39 } 40 } 41 } 42 int getAns(int a,int b,int c) 43 { 44 if (a<=0 || b<=0 || c<=0) return 1; 45 if (a>20 || b>20 || c>20) return dp[21][21][21]; 46 return dp[a+1][b+1][c+1]; 47 } 48 int main() 49 { 50 Dp(); 51 int a,b,c; 52 while (scanf("%d%d%d",&a,&b,&c) && !(a==-1 && b==-1 && c==-1)) 53 { 54 printf("w(%d, %d, %d) = %d\n",a,b,c,getAns(a,b,c)); 55 } 56 return 0; 57 }
标签:style blog http color os io for art
原文地址:http://www.cnblogs.com/djingjing/p/3899618.html