QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640364 | #5040. Dirichlet $k$-th root | the_fool | WA | 31ms | 16740kb | C++20 | 1.4kb | 2024-10-14 11:24:02 | 2024-10-14 11:24:03 |
Judging History
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'