3 条题解

  • 1

    #include<bits/stdc++.h> using namespace std; long long keep[21][21][21]; long long w(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 w(20, 20, 20); if(keep[a][b][c] != 0)return keep[a][b][c]; if(a < b && b < c) { keep[a][b][c] = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c); return keep[a][b][c]; } else { keep[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 keep[a][b][c]; } } int main() { long long a[1000], b[1000], c[1000], i = 1; keep[0][0][0]=1; keep[20][20][20]=1048576; for(;; i++) { cin >> a[i] >> b[i] >> c[i]; if(a[i] == -1 && b[i] == -1 && c[i] == -1)break; } for(int j=1; j<i; j++)cout << "w(" << a[j] << ", " << b[j] << ", " << c[j] << ") = " << w(a[j], b[j], c[j]) << "\n"; }

    这题解呢,是对的,但是超时了[呜呜呜]

    信息

    ID
    5522
    时间
    1000ms
    内存
    125MiB
    难度
    2
    标签
    递交数
    169
    已通过
    50
    上传者