1 solutions

  • 0
    @ 2023-12-3 21:35:15

    C++ :

    #include <bits/stdc++.h>
    #define mset(a, b) memset(a, b, sizeof(a))
    #define rg register
    using namespace std;
    typedef long long LL;
    const int N = 10;
    const LL MOD = 2148473648LL;
    
    template <typename T>
    inline void read(T &AKNOI) {
        T x = 0, flag = 1;
        char ch = getchar();
        while (!isdigit(ch)) {
            if (ch == '-')
                flag = -1;
            ch = getchar();
        }
        while (isdigit(ch)) {
            x = x * 10 + ch - '0';
            ch = getchar();
        }
        AKNOI = flag * x;
    }
    
    template <typename T>
    inline void cmin(T &x, T y) {
        if (x > y)
            x = y;
    }
    template <typename T>
    inline void cmax(T &x, T y) {
        if (x < y)
            x = y;
    }
    
    LL ans[N];
    
    void solve() {
        mset(ans, 0);
        ans[0] = 1;
        for (int i = 0; i < 4; ++i) {
            int x;
            read(x);
            if (x == 1) {
                for (int j = 8; j >= 2; --j) {
                    ans[j] = ans[j - 2];
                }
                ans[0] = ans[1] = 0;
            } else {
                for (int j = 8; j >= 1; --j) {
                    ans[j] = (ans[j] * (x - 2) + ans[j - 1] * 2) % MOD;
                }
                ans[0] = ans[0] * (x - 2) % MOD;
            }
        }
        for (int j = 0; j <= 8; ++j) {
            printf("%lld ", ans[j]);
        }
        printf("\n");
    }
    
    int main() {
        int T;
        read(T);
        while (T--) {
            solve();
        }
        return 0;
    }
    
    • 1

    Information

    ID
    1313
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By