求解

P1464 Function

@[深附哲学组织](/user/255540) 35 35 35 直接RE
by WYXkk @ 2020-02-20 18:10:01


你不觉得abc可能很大吗,进函数之前就要判一次
by pidan @ 2020-02-20 18:11:20


记忆化递归
by Dimly_dust @ 2020-02-20 18:26:48


本人改了一改,发现变成了全WA,各位dalao照顾一手,代码走起!```cpp #include <cstdio> long long fuc[30][30][30]={0}; int w(long long a,long long b,long long c) { if(a<=0 || b<=0 || c<=0) { return 1; } else if(a>20 || b>20 || c>20) { if(fuc[a][b][c]!=0) return fuc[a][b][c]; return fuc[a][b][c]=w(20,20,20); } else if(a<b && b<c) { if(fuc[a][b][c]!=0) return fuc[a][b][c]; return fuc[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); } else { if(fuc[a][b][c]!=0) return fuc[a][b][c]; return fuc[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); } } int main() { long long a=0,b=0,c=0; long long ans; while(a!=-1 && b!=-1 && c!=-1) { scanf("%lld %lld %lld",&a,&b,&c); if(a==-1&&b==-1&&c==-1) { break; return 0; } if(a>20 || b>20 || c>20) ans=w(21,21,21); else if(a<=0 || b<=0 || c<=0) ans=1; else ans=w(a,b,c); printf("w(%lld,%lld,%lld)=%lld\n",a,b,c,ans); } return 0; } ```
by Her_Lingxiao @ 2020-02-20 20:31:34


|