QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#590951 | #8635. 圆 | xiay | 20 | 41ms | 3852kb | C++14 | 695b | 2024-09-26 13:15:13 | 2024-09-26 13:15:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 5, P = 998244353;
int dp[N], n;
long long qpow(long long a, int b) {
long long ans = 1;
while (b) {
if (b & 1) {
ans = ans * a % P;
}
a = a * a % P;
b >>= 1;
}
return ans;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#endif
scanf("%d", &n);
dp[1] = 0;
dp[2] = 0;
for (int i = 3; i <= n - 1; i++) {
int sum = 0;
for (int j = 1; j <= i; j++) {
sum = (sum + (dp[j - 1] + dp[i - j]) % P) % P;
}
sum = 1ll * sum * qpow(i, P - 2) % P;
dp[i] = sum + 1;
}
printf("%d", dp[n - 1] + 1);
return 0;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 10
Accepted
time: 0ms
memory: 3812kb
input:
4
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 3792kb
input:
6
output:
3
result:
wrong answer 1st numbers differ - expected: '299473309', found: '3'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3764kb
input:
10
output:
5
result:
wrong answer 1st numbers differ - expected: '487238321', found: '5'
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 3724kb
input:
100
output:
50
result:
wrong answer 1st numbers differ - expected: '41620761', found: '50'
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3652kb
input:
200
output:
100
result:
wrong answer 1st numbers differ - expected: '208771764', found: '100'
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 3792kb
input:
500
output:
250
result:
wrong answer 1st numbers differ - expected: '888621375', found: '250'
Test #8:
score: 0
Wrong Answer
time: 34ms
memory: 3664kb
input:
4798
output:
2399
result:
wrong answer 1st numbers differ - expected: '319137015', found: '2399'
Test #9:
score: 0
Wrong Answer
time: 41ms
memory: 3832kb
input:
4999
output:
499124676
result:
wrong answer 1st numbers differ - expected: '818467659', found: '499124676'
Test #10:
score: 0
Wrong Answer
time: 37ms
memory: 3852kb
input:
5000
output:
2500
result:
wrong answer 1st numbers differ - expected: '142907477', found: '2500'