443eb9 @ 2024-10-01 12:40:20
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
ll rec[21][21][21]{};
function<ll(ll, ll, ll)> w = [&](ll x, ll y, ll z) {
if (x <= 0 || y <= 0 || z <= 0) return (ll)1;
if (x > 20 || y > 20 || z > 20) return w(20, 20, 20);
if (rec[x][y][z] != 0) return rec[x][y][z];
ll res = 0;
if (x < y && y < z)
res = w(x, y, z - 1) + w(x, y - 1, z - 1) - w(x, y - 1, z);
else
res = w(x - 1, y, z) + w(x - 1, y - 1, z) + w(x - 1, y, z - 1) - w(x - 1, y - 1, z - 1);
rec[x][y][z] = res;
return res;
};
ll a, b, c;
while (true) {
scanf("%lld%lld%lld", &a, &b, &c);
if (a == -1 && b == -1 && c == -1) break;
printf("w(%lld, %lld, %lld) = %lld", a, b, c, w(a, b, c));
}
return 0;
}
by 虫二bug2 @ 2024-11-08 00:19:07
@443eb9 哥们你没换行啊:
printf("w(%lld, %lld, %lld) = %lld\n", a, b, c, w(a, b, c));