全TLE

P1464 Function

你的记忆化呢
by TernaryTree @ 2022-08-14 15:39:57


记忆化,数组
by A_HissingCreeper @ 2022-08-14 16:23:32


```cpp #include<bits/stdc++.h> using namespace std; int w[25][25][25]; int main(){ int a,b,c; for(int i=0;i<=20;++i) for(int j=0;j<=20;++j) for(int k=0;k<=20;++k) w[i][j][k]=1; for(int i=1;i<=20;++i) for(int j=1;j<=20;++j) for(int k=1;k<=20;++k) w[i][j][k]=w[i-1][j][k]+w[i-1][j-1][k]+w[i-1][j][k-1]-w[i-1][j-1][k-1]; while(true){ scanf("%d%d%d",&a,&b,&c); if (a==-1&&b==-1&&c==-1) return 0; if (a<=0||b<=0||c<=0){ printf("w(%d, %d, %d) = %d\n",a,b,c,1); continue; } if (a>20||b>20||c>20){ printf("w(%d, %d, %d) = %d\n",a,b,c,w[20][20][20]); continue; } printf("w(%d, %d, %d) = %d\n",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 0; } ```
by slitherin @ 2022-08-14 16:38:58


|