QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#503522 | #9116. DRD String | ucup-team191# | WA | 7ms | 9464kb | C++23 | 827b | 2024-08-03 19:41:10 | 2024-08-03 19:41:11 |
Judging History
answer
#include <cstdio>
using namespace std;
const int N = 1e6 + 500;
const int MOD = 998244353;
inline int add(int A, int B ) {
if(A + B >= MOD) return A + B - MOD;
return A + B;
}
inline int sub(int A, int B ) {
if(A - B < 0) return A - B + MOD;
return A - B;
}
inline int mul(int A, int B) {
return (long long)A * B % MOD;
}
int potm[N], n, m, clean[N];
int main() {
scanf("%d%d", &n, &m);
potm[0] = 1;
for(int i = 1;i < N;i++) potm[i] = mul(potm[i - 1], m);
clean[1] = m;
clean[2] = m * (m - 1);
int suma = m;
for(int i = 3;i <= n;i++) {
suma = mul(suma, m);
if(i % 2 == 0) suma = add(suma, clean[i / 2]);
clean[i] = sub(potm[i], suma);
}
int ans = 0;
for(int i = 1;2 * i < n;i++) {
ans = add(ans, mul(potm[n - 2 * i], clean[i]));
}
printf("%d\n", ans);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5908kb
input:
6 2
output:
40
result:
ok "40"
Test #2:
score: 0
Accepted
time: 5ms
memory: 6000kb
input:
3017 7801
output:
515391664
result:
ok "515391664"
Test #3:
score: 0
Accepted
time: 5ms
memory: 5548kb
input:
3 1
output:
1
result:
ok "1"
Test #4:
score: 0
Accepted
time: 5ms
memory: 5700kb
input:
4 7
output:
343
result:
ok "343"
Test #5:
score: 0
Accepted
time: 5ms
memory: 7092kb
input:
5 4
output:
304
result:
ok "304"
Test #6:
score: 0
Accepted
time: 0ms
memory: 7484kb
input:
8 8
output:
2355200
result:
ok "2355200"
Test #7:
score: 0
Accepted
time: 5ms
memory: 6404kb
input:
7 6
output:
54216
result:
ok "54216"
Test #8:
score: 0
Accepted
time: 5ms
memory: 7524kb
input:
1330 3031
output:
139921223
result:
ok "139921223"
Test #9:
score: 0
Accepted
time: 2ms
memory: 6320kb
input:
4946 3837
output:
64102067
result:
ok "64102067"
Test #10:
score: 0
Accepted
time: 0ms
memory: 7044kb
input:
4236 3305
output:
78581604
result:
ok "78581604"
Test #11:
score: 0
Accepted
time: 4ms
memory: 6136kb
input:
399 3245
output:
714500544
result:
ok "714500544"
Test #12:
score: 0
Accepted
time: 5ms
memory: 7408kb
input:
4881 2346
output:
28365995
result:
ok "28365995"
Test #13:
score: 0
Accepted
time: 5ms
memory: 7092kb
input:
4647 3069
output:
798067847
result:
ok "798067847"
Test #14:
score: 0
Accepted
time: 2ms
memory: 7328kb
input:
3414 4280
output:
669878613
result:
ok "669878613"
Test #15:
score: -100
Wrong Answer
time: 7ms
memory: 9464kb
input:
1000000 1000000
output:
736522432
result:
wrong answer 1st words differ - expected: '469217978', found: '736522432'