nahida_badminton @ 2023-10-14 21:43:52
一个蒟蒻的代码。。。连数据都输不进去然鹅debug了半天居然没发现是哪有问题(逆天
#include <cstdio>
#define ll long long
ll n[25][25][25] = {};
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){
if (n[a][b][c - 1] == 0)
n[a][b][c - 1] = w(a, b, c - 1);
if (n[a][b - 1][c - 1] == 0)
n[a][b - 1][c - 1] = w(a, b - 1, c - 1);
if (n[a][b - 1][c] == 0)
n[a][b - 1][c] = w(a, b - 1, c);
n[a][b][c] = n[a][b][c - 1] + n[a][b - 1][c - 1] - n[a][b - 1][c];
} else {
if (n[a - 1][b][c] == 0)
n[a - 1][b][c] = w(a - 1, b, c);
if (n[a - 1][b - 1][c] == 0)
n[a - 1][b - 1][c] = w(a - 1, b - 1, c);
if (n[a - 1][b][c - 1] == 0)
n[a - 1][b][c - 1] = w(a - 1, b, c - 1);
if (n[a - 1][b - 1][c - 1] == 0){
n[a - 1][b - 1][c - 1] = w(a - 1, b - 1, c - 1);
n[a][b][c] = n[a - 1][b][c] + n[a - 1][b - 1][c] + n[a - 1][b][c - 1] - n[a - 1][b - 1][c - 1];
}
}
return n[a][b][c];
}
int main(){
ll a, b, c;
while(scanf("lld lld lld", &a, &b, &c)){
if (a == -1 && b == -1 && c == -1) break;
printf("w(%lld, %lld, %lld) = ", a, b, c);
if (a > 20) a = 21;
if (b > 20) b = 21;
if (c > 20) c = 21;
printf("%lld\n", w(a, b, c));
}
return 0;
}
by Genshineer @ 2023-10-14 21:46:11
您scanf的百分号捏?
by Feirness_ @ 2023-10-14 21:47:19
请问一下,到底是没有输入还是输出啊
by Genshineer @ 2023-10-14 21:50:06
while(scanf("%lld %lld %lld", &a, &b, &c)){
···
}
by Feirness_ @ 2023-10-14 22:03:29
顺带说一句,scanf改了T了哦