|
沙发
楼主 |
发表于 2019-11-1 20:59:07
|
只看该作者
- #include<stdio.h>
- int f[21][21][21];
- int aa[10000],bb[10000],cc[10000];
- int w(int a,int b,int c)
- {
- if(a<=0||b<=0||c<=0) return 1;
- if(a>20||b>20||c>20) return w(20,20,20);
- if(f[a][b][c] != f[0][0][0]) return f[a][b][c];
- if(a<b&&b<c) f[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
- else f[a][b][c] = w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
- return f[a][b][c];
- }
- int main(){
- int a,b,c,i,ii;
- i=0;
- while(a!=-1||b!=-1||c!=-1){
- scanf("%d %d %d",&a,&b,&c);
- aa[i]=a;bb[i]=b;cc[i]=c;
- i++;
- }
- for(ii=0;ii<i-2;ii++){printf("w(%d, %d, %d) = %d \n",aa[ii],bb[ii],cc[ii],w(aa[ii],bb[ii],cc[ii]));}
- printf("w(%d, %d, %d) = %d",aa[ii],bb[ii],cc[ii],w(aa[ii],bb[ii],cc[ii]));
- return 0;
- }
复制代码
菜鸡做法
|
|