5个TLE!!!求助!!!

P1464 Function

可以手算呀
by huangzirui @ 2017-08-15 13:28:47


Help! Help! Help! Help! Help! Help! Help! Help!
by zhangyuxing @ 2017-08-15 16:08:37


```cpp #include<bits/stdc++.h> using namespace std; #define ll long long ll w(ll a,ll b,ll c){ if(a<=0||b<=0||c<=0){ return 1; } if(a>20||b>20||c>20) return w(20,20,20); if(a==b&&b==c) return pow(2,a); if(a<=b) return pow(2,a); if(a<b&&b<c) return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c); else return 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() { ll x=1,y=1,z=1,n; while(1){ cin>>x>>y>>z; if(x==-1&&y==-1&&z==-1) break; n=w(x,y,z); cout<<"w("<<x<<", "<<y<<", "<<z<<") = "<<n<<endl; } return 0; } ```
by 天问 @ 2017-08-16 17:31:35


直接递归会完蛋的...QAQ
by Tsukimaru @ 2017-08-19 15:34:51


请手动递推
by middle_set @ 2017-10-04 12:49:53


|