简单开始,我要拿下这些题目
这题选的比较水,慢慢来
#include<iostream>
using namespace std;
int re[21][21][21];
int run(int a,int b,int c)
{
if(a<=0||b<=0||c<=0) return re[0][0][0];
if(a>20||b>20||c>20)
{
if(re[20][20][20]) return re[20][20][20];
return re[20][20][20]=run(20,20,20);
}
if(a<b&&b<c)
{
if(!re[a][b][c-1]) re[a][b][c-1]=run(a,b,c-1);
if(!re[a][b-1][c-1]) re[a][b-1][c-1]=run(a,b-1,c-1);
if(!re[a][b-1][c]) re[a][b-1][c]=run(a,b-1,c);
return re[a][b][c-1]+re[a][b-1][c-1]-re[a][b-1][c];
}
if(!re[a-1][b][c]) re[a-1][b][c]=run(a-1,b,c);
if(!re[a-1][b-1][c]) re[a-1][b-1][c]=run(a-1,b-1,c);
if(!re[a-1][b][c-1]) re[a-1][b][c-1]=run(a-1,b,c-1);
if(!re[a-1][b-1][c-1]) re[a-1][b-1][c-1]=run(a-1,b-1,c-1);
return re[a-1][b][c]+re[a-1][b-1][c]+re[a-1][b][c-1]-re[a-1][b-1][c-1];
}
int main()
{
memset(re,0,sizeof(re));
re[0][0][0]=1;
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(a==-1&&b==-1&&c==-1) break;
printf("w(%d, %d, %d) = %d\n",a,b,c,run(a,b,c));
}
return 0;
}