lizhaoqi @ 2023-11-18 10:41:37
using namespace std;
long long ans[25][25][25];
long long f(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){
return ans[20][20][20]?ans[20][20][20]:ans[20][20][20]=f(20,20,20);
}
if(a<b&b<c){
return ans[a][b][c]?ans[a][b][c]:ans[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c);
}
return ans[a][b][c]?ans[a][b][c]:ans[a][b][c]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1);
}
int main(){
long long a,b,c;
cin>>a>>b>>c;
while(a+1||b+1||c+1){
printf("w(%lld,%lld,%lld)=%lld\n",a,b,c,f(a,b,c));
cin>>a>>b>>c;
}
return 0;
}
这个代码样例通过,但交上去全WA,请大佬帮忙看看
by luogu10086 @ 2023-11-18 10:54:27
@lizhaoqi
printf("w(%lld,%lld,%lld)=%lld\n",a,b,c,f(a,b,c));
改成
printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,f(a,b,c));
by lizhaoqi @ 2023-11-18 11:10:28
@luogu10086 感谢!!!