QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#367175 | #6736. Alice and Bob | whopxx | TL | 259ms | 81760kb | C++20 | 898b | 2024-03-25 19:55:51 | 2024-03-25 19:55:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 1e7 + 10;
int a[N];
void init(){
a[0] = 1;
for(int i = 1; i <= 1e7 + 2; i++){
a[i] = a[i - 1] * i % mod;
}
}
int ksm(int a,int b){
int res = 1;
while(b){
if(b & 1){
res = res * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return res % mod;
}
int A(int n,int m){
if(n - m < 0)return 0;
return a[n] * ksm(a[n - m], mod - 2) % mod;
}
void solve(){
init();
int n;
cin >> n;
int ans = 0;
for(int x = 1; x <= n; x++){
ans += A(n - x,x - 1) * A(n - x,n - x) % mod;
ans %= mod;
}
cout << ans % mod << '\n';
}
signed main(){
int _(1);
// cin >> _;
while(_ --){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 39ms
memory: 81672kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 43ms
memory: 81760kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 47ms
memory: 81716kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 39ms
memory: 81612kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 39ms
memory: 81760kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 31ms
memory: 81612kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 35ms
memory: 81680kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 33ms
memory: 81660kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 38ms
memory: 81732kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 51ms
memory: 81716kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 41ms
memory: 81712kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 50ms
memory: 81760kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 45ms
memory: 81716kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 259ms
memory: 81608kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: -100
Time Limit Exceeded
input:
7579013