QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#642258#9437. Solve with Friendsucup-team4992WA 9ms4700kbC++142.0kb2024-10-15 12:26:042024-10-15 12:26:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 12:26:08]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:4700kb
  • [2024-10-15 12:26:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;

struct Matrix {
    ll sum[55][55];
    Matrix() {
        for (int i = 0; i <= 48; i++)
            for (int j = 0; j <= 48; j++)
                sum[i][j] = 0;
    }
    void set() {
        for (int i = 0; i <= 48; i++)
            sum[i][i] = 1;
    }
    friend Matrix operator*(const Matrix &a, const Matrix &b) {
        Matrix c;
        for (int i = 0; i <= 48; i++)
            for (int j = 0; j <= 48; j++)
                for (int k = 0; k <= 48; k++)
                    c.sum[i][j] = (c.sum[i][j] + a.sum[i][k] * b.sum[k][j] % mod) % mod;
        return c;
    }
} base;
Matrix pw[44];
Matrix POW(Matrix x, int y) {
    Matrix res;
    res.set();
    for (; y; y >>= 1) {
        if (y & 1) res = res * x;
        x = x * x;
    }
    return res;
}

void init() {
    base.set();
    for (int i = 0; i <= 48; i++) {
        int res = 0;
        if (i % 7 < 6) base.sum[i][i + 1] = 1, res++;
        if (i / 7 < 6) base.sum[i][i + 7] = 1, res++;
        base.sum[i][i] = 52 - res;
    }
    pw[0] = base;
    for (int i = 1; i <= 32; i++) {
        pw[i] = pw[i - 1] * pw[i - 1];
    }
    return;
}

int n;

void solve() {
    cin >> n;
    if (n < 12) {
        cout << 0 << '\n';
        return;
    }
    vector<ll> a(55 + 1);
    a[48] = 1;
    for (int bt = 0; bt <= 30; bt++) {
        if (!(n >> bt & 1)) continue;
        vector<ll> b(55 + 1);
        // for (int i = 1; i <= 48; i++)
        //     b[i] = 0;
        for (int i = 0; i <= 48; i++) {
            for (int j = 0; j <= 48; j++) {
                b[i] += pw[bt].sum[i][j] * a[j] % mod;
                b[i] %= mod;
            }
        }
        a = b;
    }
    cout << a[0] << '\n';
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    int T;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 4700kb

input:

3
1 3 5
6 4 2
1 2 3
1 2 3

output:

0
0
0

result:

wrong answer 1st words differ - expected: '10', found: '0'