全TLE

P1464 Function

希望更丰富的展现?使用Markdown
by BLUE_EYE @ 2018-10-25 20:43:37


```cpp #include<bits/stdc++.h> using namespace std; long long jy[200][200][200],a,b,c; int move(int a,int b,int c) { if (jy[a][b][c]!=0) return jy[a][b][c]; if (a<=0||b<=0||c<=0) {return 1;} if (a>20||b>20||c>20) {if (jy[a][b][c]==0) jy[a][b][c]=move(20,20,20);return move(20,20,20);} if (a<b&&b<c) {if (jy[a][b][c]==0) jy[a][b][c]=move(a,b,c-1)+move(a,b-1,c-1)-move(a,b-1,c);return move(a,b,c-1)+move(a,b-1,c-1)-move(a,b-1,c);} if (jy[a][b][c]==0) jy[a][b][c]=move(a-1,b,c)+move(a-1,b-1,c)+move(a-1,b,c-1)-move(a-1,b-1,c-1); return move(a-1,b,c)+move(a-1,b-1,c)+move(a-1,b,c-1)-move(a-1,b-1,c-1); } int main() { while(1) { cin>>a>>b>>c; if (a==-1&&b==-1&&c==-1) return 0; cout<<"w("<<a<<", "<<b<<", "<<c<<") = "; if (a<=0||b<=0||c<=0) {cout<<1<<endl;continue;} cout<<move(a,b,c)<<endl; if (jy[a][b][c]!=0) jy[a][b][c]=move(a,b,c); } } ```
by ⚡小林孑⚡ @ 2018-10-25 20:43:54


把每次$if$后边的$return$去掉试试
by zybnxy @ 2018-10-25 20:44:52


最后要$return$ $jy[a][b][c]$
by zybnxy @ 2018-10-25 20:46:54


帮你改好了。 ```cpp #include<bits/stdc++.h> using namespace std; long long jy[200][200][200],a,b,c; int move(int a,int b,int c) { if (jy[a][b][c]!=0) return jy[a][b][c]; if (a<=0||b<=0||c<=0) {return 1;} if (a>20||b>20||c>20) {if (jy[a][b][c]==0) jy[a][b][c]=move(20,20,20);} if (a<b&&b<c) {if (jy[a][b][c]==0) jy[a][b][c]=move(a,b,c-1)+move(a,b-1,c-1)-move(a,b-1,c);} if (jy[a][b][c]==0) jy[a][b][c]=move(a-1,b,c)+move(a-1,b-1,c)+move(a-1,b,c-1)-move(a-1,b-1,c-1); return jy[a][b][c]; } int main() { while(1) { cin>>a>>b>>c; if (a==-1&&b==-1&&c==-1) return 0; cout<<"w("<<a<<", "<<b<<", "<<c<<") = "; if (a<=0||b<=0||c<=0) {cout<<1<<endl;continue;} cout<<move(a,b,c)<<endl; if (jy[a][b][c]!=0) jy[a][b][c]=move(a,b,c); } } ```
by zybnxy @ 2018-10-25 20:47:17


@[zws666](/space/show?uid=119959)
by zybnxy @ 2018-10-25 20:47:30


@[liuchenyu](/space/show?uid=108476)
by zybnxy @ 2018-10-25 20:48:03


@[liuchenyu](/space/show?uid=108476)
by lion0514 @ 2018-11-20 21:59:32


|