20pts求调
  • 板块P1464 Function
  • 楼主lyt_tcsn
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/1/17 20:28
  • 上次更新2025/1/18 09:03:44
查看原帖
20pts求调
1528563
lyt_tcsn楼主2025/1/17 20:28
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL ans[25][25][25];
LL w(LL a, LL b, LL c) {
    if (a > 20 || b > 20 || c > 20) return w(20, 20, 20);
    if (a <= 0 || b <= 0 || c <= 0) return 1;
    if (ans[a][b][c] != -1) return ans[a][b][c];
    if (a < b && b < c)
        return 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] = (w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1));
}
int main() {
    LL a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    while (a != -1 && b != -1 && c != -1) {
        memset(ans, -1, sizeof(ans));
        printf("w(%lld, %lld, %lld) = %lld\n", a, b, c, w(a, b, c));
        scanf("%lld%lld%lld", &a, &b, &c);
    }
    return 0;
}
2025/1/17 20:28
加载中...