综上,总复杂度是 $O(n\log n\log k)$ 的(简略逆元 $k$ 的写法),可以通过。
# Code
```cpp
int fp(int a, int n, int p) {
int res = 1;
while (n) {
if (n & 1) res = 1LL * res * a % p;
a = 1LL * a * a % p;
n >>= 1;
}
return res;
}
const auto mul(const std::vector<int>& a, const std::vector<int>& b, int p) {
int n = b.size() - 1;
std::vector<int> res(n + 1);
for (int i = 1; i * i <= n; i++) {
res[i * i] = (1LL * res[i * i] + 1LL * a[i] * b[i]) % p;
for (int j = i + 1; i * j <= n; j++) {
res[i * j] = (1LL * res[i * j] + 1LL * a[i] * b[j] + 1LL * a[j] * b[i]) % p;
}
}
return res;
}
const auto fp(std::vector<int>& a, int n, int p) {
std::vector<int> res(a.size());
res[1] = 1;
while (n) {
if (n & 1) res = mul(res, a, p);
a = mul(a, a, p);
n >>= 1;
}
return res;
}
void solve() {
int n, k;
std::cin >> n >> k;
std::vector<int> g(n + 1);
for (int i = 1; i <= n; i++) std::cin >> g[i];
k = fp(k, MOD - 2, MOD);
g = fp(g, k, MOD);
for (int i = 1; i <= n; i++) std::cout << g[i] << " \n"[i == n];
}
```