coder_1746 @ 2022-06-01 21:29:04
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x,y,z,A[500];
int 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 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(){
for(;;){
cin>>x>>y>>z;
if(x==y==z==-1) break;
else cout<<"w("<<x<<","<<y<<","<<z<<") = " <<w(x,y,z)<<endl;
}
return 0;
}
本蒟蒻怀疑点:
1、for(;;)
是不是没停下来,没有break,导致T掉?
2、是不是数据太大,函数这里出了问题T掉?
P.S.本蒟蒻不会记忆化搜索,本体能做吗...
by yuer_qwq @ 2022-06-01 21:29:49
你们都好卷啊,就我最菜
by coder_1746 @ 2022-06-01 21:30:15
更正,最后一句话是:
P.S.本蒟蒻不会记忆化搜索,本题能做吗?
by coder_1746 @ 2022-06-01 21:30:49
@chenyuer azzz,这不要月赛了吗...(你不卷吗)
by yuer_qwq @ 2022-06-01 21:31:07
@coder_1746 只会颓废
by Super_Supper @ 2022-06-01 21:32:16
月赛你紧张个毛线,期末考还说的过去
by Hughpig @ 2022-06-01 21:32:23
要记忆化搜索。就是搜索结果要记下来,方便调用,否则会TLE
by yuer_qwq @ 2022-06-01 21:33:26
啊啊啊我的同学们全在卷
by coder_1746 @ 2022-06-01 21:35:15
@Hughzhuxiuqi 所以我去翻ybt去了...
by Hughpig @ 2022-06-01 21:35:30
@coder_1746 即算出一个状态就要存下来
by zzr1 @ 2022-06-01 21:39:20
@coder_1746 月赛很简单的,怕个屁