watchout666 @ 2024-04-06 09:58:09
c++上运行都没问题的!
#include<bits/stdc++.h>
using namespace std;
long long ans[25][25][25];
long long w(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 w(20,20,20);
if(ans[a][b][c] != 0) return ans[a][b][c];
if(a<b&&b<c){
ans[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
return ans[a][b][c];
}
ans[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 ans[a][b][c];
}
int main(){
long long a,b,c;
while(true){
scanf("%lld%lld%lld",&a,&b,&c);
if(a==-1&&b==-1&&c==-1) break;
long long ans = w(a,b,c);
printf("w(%lld,%lld,%lld) = %lld\n",a,b,c,w(a,b,c));
}
return 0;
}
by rhn7 @ 2024-04-06 10:12:24
输出格式有问题
printf("w(%lld,%lld,%lld) = %lld\n",a,b,c,w(a,b,c));
改成
printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
by watchout666 @ 2024-04-06 10:14:30
@rhn7 OK,AC了
by BGM114514 @ 2024-04-06 10:14:49
@watchout666 为神马和隔壁代码一样
by YQJ1024 @ 2024-04-06 11:13:47
gfhmFASGRHDTJFKGYLUHI;O