QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204399 | #6736. Alice and Bob | kiwiHM# | WA | 1ms | 5860kb | C++14 | 842b | 2023-10-07 11:05:47 | 2023-10-07 11:05:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 5;
const int INF = 998244353;
int n;
int fac[maxn], ifac[maxn];
inline int qpow(int x, int y){
int ret = 1;
for(; y; y >>= 1){
if(y & 1) ret = 1ll * ret * x % INF;
x = 1ll * x * x % INF;
}
return ret;
}
inline int binom(int x, int y){
if(x > y) return 0;
return 1ll * fac[x] * ifac[y] % INF * ifac[x - y] % INF;
}
int main(){
scanf("%d", &n);
fac[0] = 1; for(int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % INF;
ifac[n] = qpow(fac[n], INF - 2); for(int i = n - 1; i >= 0; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % INF;
int ans = 0;
for(int i = 1; i <= n; ++i){
int res = 1ll * fac[n - i] * ifac[(n - i) - (i - 1)] % INF * fac[n - i] % INF;
ans = (ans + res) % INF;
}
printf("%d\n", ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5860kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5656kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5820kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 5656kb
input:
100
output:
686877341
result:
wrong answer 1st numbers differ - expected: '188898954', found: '686877341'