3*WA,7*TLE求助!

P1464 Function

@[Harry_Haiyun](/user/977778) 都define了怎么不用ull?
by 2011FYCCCTA @ 2023-08-08 15:33:27


还有要记忆化
by 2011FYCCCTA @ 2023-08-08 15:34:24


不行,全TLE
by __Harry_Haiyun__ @ 2023-08-08 19:13:21


@[__Harry_Haiyun__](/user/977778) 这么写就对 ```cpp #include <iostream> #include <bits/stdc++.h> using namespace std; int ans[25][25][25]; long long w(long long a,long long b,long long c) { if(a<=0||b<=0||c<=0) return 1; if(a>20||b>20||c>20) a=b=c=21; if(ans[a][b][c]) return ans[a][b][c]; if(a>20||b>20||c>20) return ans[a][b][c]=w(20,20,20); if(a<b&&b<c) return ans[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); return ans[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() { while(1) { long long x,y,z; cin>>x>>y>>z; if(x==-1&&y==-1&&z==-1)break; printf("w(%lld, %lld, %lld) = %d\n",x,y,z,w(x,y,z)); } return 0; } ```
by Li_wc0802 @ 2023-08-18 08:06:45


|