TheIceStar @ 2022-08-06 21:19:19
#include <iostream>
using namespace std;
long long memory[25][25][25];
long long clac(long long a, long long b, long long c);
int main(){
long long a = 0;
long long b = 0;
long long c = 0;
cin>>a>>b>>c;
while (a != -1 && b!=-1 && c!=-1){
cout << "w" << "(" << a << ", " << b << ", " << c << ") = " << clac(a, b, c) << endl;
// cout << a << b << c;
cin>>a>>b>>c;
}
return 0;
}
long long clac(long long a, long long b, long long c){
if (a <= 0 || b <= 0 || c <= 0){
return 1;
}
else if (a > 20 || b > 20 || c > 20){
return (clac(20, 20, 20));
}
else if (memory[a][b][c]){
return (memory[a][b][c]);
}
else if (a < b && b < c){
memory[a][b][c] = clac(a,b,c-1)+clac(a,b-1,c-1)-clac(a,b-1,c);
}
memory[a][b][c] = clac(a-1,b,c)+clac(a-1,b-1,c)+clac(a-1,b,c-1)-clac(a-1,b-1,c-1);
return memory[a][b][c];
}
啊只有中间一个AC了其他都WA了,help, help
by Always_Remember_It @ 2022-08-06 21:33:41
@TheIceStar 少了个else
by TheIceStar @ 2022-08-06 21:40:26
#include <iostream>
using namespace std;
long long memory[25][25][25];
long long clac(long long a, long long b, long long c);
int main(){
long long a = 0;
long long b = 0;
long long c = 0;
cin>>a>>b>>c;
while (a != -1 && b!=-1 && c!=-1){
cout << "w" << "(" << a << ", " << b << ", " << c << ") = " << clac(a, b, c) << endl;
// cout << a << b << c;
cin>>a>>b>>c;
}
return 0;
}
long long clac(long long a, long long b, long long c){
if (a <= 0 || b <= 0 || c <= 0){
return 1;
}
else if (a > 20 || b > 20 || c > 20){
return (clac(20, 20, 20));
}
else if (memory[a][b][c]){
return (memory[a][b][c]);
}
else if (a < b && b < c){
memory[a][b][c] = clac(a,b,c-1)+clac(a,b-1,c-1)-clac(a,b-1,c);
}
else {
memory[a][b][c] = clac(a-1,b,c)+clac(a-1,b-1,c)+clac(a-1,b,c-1)-clac(a-1,b-1,c-1);
}
return memory[a][b][c];
}
以上是修改的并提交的代码 但是依旧没有全AC 感谢你的回复
by Always_Remember_It @ 2022-08-06 21:44:18
@TheIceStar 我再看看(前面用手机不好调)
by Always_Remember_It @ 2022-08-06 21:51:38
@TheIceStar while (a != -1 || b!=-1 || c!=-1){
by TheIceStar @ 2022-08-06 21:53:49
谢谢你