QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#181736 | #4908. 完全表示 | zhoukangyang | 30 | 71ms | 17948kb | C++11 | 2.3kb | 2023-09-16 23:06:11 | 2023-09-16 23:06:12 |
Judging History
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector < int >
#define sz(a) ((int) (a).size())
#define ll long long
#define ull unsigned long long
#define me(a, x) memset(a, x, sizeof(a))
using namespace std;
const int N = 1 << 19, mod = 164511353;
int qpow(int x, int y = mod - 2) {
int res = 1;
for(; y; x = (ll) x * x % mod, y >>= 1) if(y & 1) res = (ll) res * x % mod;
return res;
}
int fac[N], ifac[N], inv[N];
void init(int x) {
fac[0] = ifac[0] = inv[1] = 1;
L(i, 2, x) inv[i] = (ll) (mod - mod / i) * inv[mod % i] % mod;
L(i, 1, x) fac[i] = (ll) fac[i - 1] * i % mod, ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
}
int C(int x, int y) {
return x < y || y < 0 ? 0 : (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
inline int sgn(int x) {
return (x & 1) ? mod - 1 : 1;
}
const int r = 41;
int n, k, m, type;
int prm[N], mt[N], rmt[N], cnt[N], top;
int fen[N];
int val[N];
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
init(N - 10);
cin >> n >> k >> m;
cin >> type;
if(type == 1) {
L(i, 2, k) if(k % i == 0) {
int c = 0;
while(k % i == 0) k /= i, ++c;
++top, prm[top] = i, cnt[top] = c, mt[top] = rmt[top] = 1;
L(j, 1, c) mt[top] *= i;
L(j, 1, c - 1) rmt[top] *= i;
}
const ll Z = (ll)mod * 41;
map < ll, int > vc;
vc[1] = 1;
L(i, 1, top) {
L(cnt, 0, n - 1) {
int qp = qpow(prm[i], cnt);
map < ll, int > nvc;
for(auto&u : vc) {
ll val = u.first;
int w = u.second;
(nvc[mt[i] * val % Z] += w) %= mod;
(nvc[rmt[i] * val % Z] += mod - (ll) qp * w % mod) %= mod;
}
swap(vc, nvc);
}
}
int ans = 0;
for(auto&s : vc) {
ll x = s.first;
int y = s.second;
int pr = (ll)y * qpow(2, x % 41) % mod;
L(i, 0, m) {
if(i) pr = (ll) pr * (x % mod - i + 1) % mod * inv[i] % mod;
(fen[i] += pr) %= mod;
}
}
L(i, 0, m)
fen[i] = (ll)fen[i] * qpow(qpow(2), i) % mod;
L(i, 0, m) {
L(j, 0, i) {
(val[j] += (ll)fen[i] * sgn(i - j) % mod * C(i, j) % mod) %= mod;
}
}
int ANS = 0;
L(i, 0, m) {
(ANS += (ll)val[i] * qpow(i, m) % mod) %= mod;
}
cout << ANS << '\n';
}
return 0;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 6ms
memory: 16404kb
input:
2 3 665 1
output:
51745605
result:
ok "51745605"
Test #2:
score: 0
Accepted
time: 5ms
memory: 16356kb
input:
2 4 641 1
output:
54153482
result:
ok "54153482"
Test #3:
score: 0
Accepted
time: 10ms
memory: 16452kb
input:
1 6 656 1
output:
119347748
result:
ok "119347748"
Test #4:
score: 0
Accepted
time: 8ms
memory: 16208kb
input:
1 8 170 1
output:
126971959
result:
ok "126971959"
Test #5:
score: 0
Accepted
time: 7ms
memory: 16540kb
input:
1 9 816 1
output:
14287284
result:
ok "14287284"
Test #6:
score: 0
Accepted
time: 8ms
memory: 15976kb
input:
1 12 233 1
output:
37178137
result:
ok "37178137"
Test #7:
score: 0
Accepted
time: 4ms
memory: 16988kb
input:
1 16 244 1
output:
91022688
result:
ok "91022688"
Test #8:
score: 0
Accepted
time: 8ms
memory: 17888kb
input:
1 18 218 1
output:
93037058
result:
ok "93037058"
Test #9:
score: 0
Accepted
time: 9ms
memory: 16784kb
input:
1 19 645 1
output:
53944276
result:
ok "53944276"
Test #10:
score: 0
Accepted
time: 4ms
memory: 16072kb
input:
1 20 333 1
output:
81197702
result:
ok "81197702"
Test #11:
score: 0
Accepted
time: 10ms
memory: 17244kb
input:
1 2 893 1
output:
17672119
result:
ok "17672119"
Test #12:
score: 0
Accepted
time: 10ms
memory: 17912kb
input:
1 19 887 1
output:
58567516
result:
ok "58567516"
Test #13:
score: 0
Accepted
time: 4ms
memory: 16672kb
input:
2 3 504 1
output:
60763909
result:
ok "60763909"
Subtask #2:
score: 15
Accepted
Test #14:
score: 15
Accepted
time: 4ms
memory: 17368kb
input:
19 90203 0 1
output:
142145213
result:
ok "142145213"
Test #15:
score: 0
Accepted
time: 4ms
memory: 17084kb
input:
18 9697 0 1
output:
153592927
result:
ok "153592927"
Test #16:
score: 0
Accepted
time: 4ms
memory: 17020kb
input:
20 41 0 1
output:
112957727
result:
ok "112957727"
Test #17:
score: 0
Accepted
time: 8ms
memory: 16852kb
input:
20 99991 0 1
output:
151341559
result:
ok "151341559"
Subtask #3:
score: 5
Accepted
Dependency #2:
100%
Accepted
Test #18:
score: 5
Accepted
time: 71ms
memory: 17532kb
input:
999 9749 0 1
output:
77370298
result:
ok "77370298"
Test #19:
score: 0
Accepted
time: 67ms
memory: 17948kb
input:
997 55103 0 1
output:
92054017
result:
ok "92054017"
Test #20:
score: 0
Accepted
time: 64ms
memory: 17940kb
input:
1000 41 0 1
output:
6438830
result:
ok "6438830"
Test #21:
score: 0
Accepted
time: 69ms
memory: 17452kb
input:
1000 99991 0 1
output:
31676606
result:
ok "31676606"
Subtask #4:
score: 0
Time Limit Exceeded
Dependency #3:
100%
Accepted
Test #22:
score: 0
Time Limit Exceeded
input:
99996 20089 0 1
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #26:
score: 0
Time Limit Exceeded
input:
998 24 0 1
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #7:
0%
Subtask #9:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 7ms
memory: 11140kb
input:
99997 3 997 2 0 1 2 1 2 0 2 0 1 0 0 0 0 1 2 0 2 1
output:
result:
wrong answer Unexpected EOF in the participants output