BaMboo45 @ 2024-01-26 20:08:30
#include<iostream>
using namespace std;
long long store[30][30][30]{0};
long long result[100000]{};
long long hh[100000][3]{};
long long a = 0, b = 0, c = 0;
int times = 0;
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 (store[a][b][c] > 0) {
return store[a][b][c];
}
if ((a < b) && (b < c)) {
store[a][b][c] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c);
return store[a][b][c];
}
store[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 store[a][b][c];
}
int main() {
for (int i = 0; (a != -1) || (b != -1) || (c != -1); i++) {
cin >> a >> b >> c;
result[i] = w(a, b, c);
hh[i][0] = a;
hh[i][1] = b;
hh[i][2] = c;
times++;
}
for (int i = 0; i < times - 1; i++) {
cout << "w(" << hh[i][0] << ", " << hh[i][1] << ", " << hh[i][2] << ") = " << result[i] << endl;
}
return 0;
}
在自己电脑上运行与期望输出值一致,但在洛谷平台提交后显示我该测试点的计算结果变为负值。
by zhangy_22 @ 2024-02-06 20:20:24
@BaMboo45 你输出应该有问题