WoodReal12 @ 2023-07-30 10:51:34
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
ll rec[25][25][25];
ll srh(ll a,ll b,ll c){
if(a<=0||b<=0||c<=0)
return rec[a][b][c]=1;
else if(rec[a][b][c]!=0)
return rec[a][b][c];
else if(a>20||b>20||c>20)
return rec[a][b][c]=srh(20,20,20);
else if(a<b&&b<c)
return rec[a][b][c]=srh(a,b,c-1)+srh(a,b-1,c-1)-srh(a,b-1,c);
else
return rec[a][b][c]=srh(a-1,b,c)+srh(a-1,b-1,c)+srh(a-1,b,c-1)-srh(a-1,b-1,c-1);
}
ll x,y,z;
int main(){
while(scanf("%lld%lld%lld",&x,&y,&z)&&x!=-1&&y!=-1&&z!=-1){
memset(rec,0,sizeof(rec));
printf("w(%lld, %lld, %lld) = %lld\n",x,y,z,srh(x,y,z));
}
system("pause");
return 0;
}
by ling66 @ 2023-08-01 18:05:58
因为它输入的数范围很大,如果输入的大于25,走到第一个else if就会出错
by H2230819096 @ 2023-08-05 00:43:17
else if(a>20||b>20||c>20) return rec[a][b][c]=srh(20,20,20); 改成else if(a>20||b>20||c>20) return srh(20,20,20);//就不会超过20的范围了