QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#699383 | #8833. Equalizer Ehrmantraut | icpc_zhzx034 | AC ✓ | 137ms | 19368kb | C++14 | 1.4kb | 2024-11-02 08:39:33 | 2024-11-02 08:39:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const ll mod = 998244353;
ll fac[N], ifac[N];
inline void get_fac(ll n) {
fac[0] = 1;
for (int i = 1; i <= n; ++i) {
fac[i] = fac[i - 1] * i % mod;
}
ifac[0] = ifac[1] = 1;
for (int i = 2; i <= n; ++i) {
ifac[i] = (mod - mod / i) * ifac[mod % i] % mod;
}
for (int i = 1; i <= n; ++i) {
ifac[i] = ifac[i] * ifac[i - 1] % mod;
}
}
inline ll A(ll n, ll m) {
if (n < m) {
return 0;
}
return fac[n] * ifac[n - m] % mod;
}
inline ll C(ll n, ll m) {
if (n < m) {
return 0;
}
return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
inline ll qpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1) {
res = res * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return res;
}
inline ll inv(ll a) {
return qpow(a, mod - 2);
}
ll n, m, ans;
inline void addmod(ll &x) {
(x >= mod) && (x -= mod);
}
int main() {
#ifdef LOCAL
assert(freopen("test.in", "r", stdin));
assert(freopen("test.out", "w", stdout));
#endif
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
get_fac(1e6);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
addmod(ans += qpow(m, n));
addmod(ans += mod - qpow(i - 1, n));
}
addmod(ans <<= 1);
addmod(ans = ans + mod - qpow(m, n));
cout << ans << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 10ms
memory: 19300kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 12ms
memory: 19240kb
input:
2 2
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 13ms
memory: 19236kb
input:
69 42
output:
608932821
result:
ok 1 number(s): "608932821"
Test #4:
score: 0
Accepted
time: 14ms
memory: 19312kb
input:
102 156
output:
748401290
result:
ok 1 number(s): "748401290"
Test #5:
score: 0
Accepted
time: 19ms
memory: 19296kb
input:
4646 95641
output:
89806680
result:
ok 1 number(s): "89806680"
Test #6:
score: 0
Accepted
time: 36ms
memory: 19232kb
input:
42849 215151
output:
242217237
result:
ok 1 number(s): "242217237"
Test #7:
score: 0
Accepted
time: 117ms
memory: 19284kb
input:
786416 794116
output:
472898000
result:
ok 1 number(s): "472898000"
Test #8:
score: 0
Accepted
time: 116ms
memory: 19352kb
input:
963852 789456
output:
353211048
result:
ok 1 number(s): "353211048"
Test #9:
score: 0
Accepted
time: 66ms
memory: 19292kb
input:
696969 424242
output:
787990158
result:
ok 1 number(s): "787990158"
Test #10:
score: 0
Accepted
time: 29ms
memory: 19368kb
input:
1000000 123456
output:
533491028
result:
ok 1 number(s): "533491028"
Test #11:
score: 0
Accepted
time: 137ms
memory: 19348kb
input:
1000000 1000000
output:
572586375
result:
ok 1 number(s): "572586375"
Test #12:
score: 0
Accepted
time: 116ms
memory: 19236kb
input:
123456 1000000
output:
486967129
result:
ok 1 number(s): "486967129"
Test #13:
score: 0
Accepted
time: 17ms
memory: 19236kb
input:
789456 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 8ms
memory: 19312kb
input:
852516 2
output:
148946358
result:
ok 1 number(s): "148946358"
Test #15:
score: 0
Accepted
time: 21ms
memory: 19228kb
input:
1 953646
output:
40087733
result:
ok 1 number(s): "40087733"
Test #16:
score: 0
Accepted
time: 13ms
memory: 19256kb
input:
3 7686
output:
278212472
result:
ok 1 number(s): "278212472"
Extra Test:
score: 0
Extra Test Passed