QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640364#5040. Dirichlet $k$-th rootthe_foolWA 31ms16740kbC++201.4kb2024-10-14 11:24:022024-10-14 11:24:03

Judging History

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

  • [2024-10-14 11:24:03]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:16740kb
  • [2024-10-14 11:24:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

constexpr int mod = 998244353;
constexpr int N = 1E5 + 10;
using ay = array<LL, N>;

LL ksm(LL a, LL b) {
    LL res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

vector<int> factor[N];
ay mul(const ay &a, const ay &b) {
    ay res = a;
    for (int i = N - 1; i > 1; i--) {
        for (int x : factor[i]) {
            res[i] += b[x] * a[i / x] % mod;
            while (res[i] >= mod) res[i] -= mod;
        }
    }
    return a;
}

ay ksm(ay a, LL b) {
    ay res = {0, 1, };
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

void solve() {
    int n, k;
    cin >> n >> k;

    ay g;
    for (int i = 1; i <= n; i++) {
        cin >> g[i];
    }
    k = ksm(k, mod - 2);
    ay f = ksm(g, k);
    for (int i = 1; i <= n; i++) {
        cout << f[i] << " \n"[i == n];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef Debug
    assert(freopen("in.txt", "r", stdin));
    assert(freopen("out.txt", "w", stdout));
#endif

    for (int i = 2; i < N; i++) {
        for (int j = i; j < N; j += i) {
            factor[j].emplace_back(i);
        }
    }

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 31ms
memory: 16740kb

input:

5 2
1 8 4 26 6

output:

1 0 0 0 0

result:

wrong answer 2nd numbers differ - expected: '4', found: '0'