QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#364584 | #6736. Alice and Bob | Atmizz# | WA | 0ms | 5656kb | C++20 | 971b | 2024-03-24 15:26:08 | 2024-03-24 15:26:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
typedef long long LL;
#define int long long
const int N = 1e7 + 20;
const int M = 1e7;
LL fac[N], inFac[N];
LL qmi(LL a, LL b) {
LL sum = 1;
while(b) {
if(b & 1LL) {
sum = sum * a % mod;
}
b >>= 1LL; a = a * a % mod;
}
return sum % mod;
}
LL C(LL n, LL m) {
return fac[n] * inFac[m] % mod * inFac[n-m] % mod;
}
signed main()
{
int n;
cin >> n;
fac[0] = 1;
for(int i = 1; i <= n; ++ i) {
fac[i] = fac[i-1] * i % mod;
}
inFac[n] = qmi(fac[n], mod - 2);
for(int i = n - 1; i >= 0; -- i) {
inFac[i] = inFac[i+1] * (i + 1) % mod;
}
vector<LL> s(n+10);
s[0]=1;
for(int i=1;i<=n;i++) s[i]=s[i-1]*i%mod;
int sum=0;
for(int x=1;x<=n;x++){
sum=(sum+C(n-x,x-1)*s[n-x]%mod*s[x-1]%mod)%mod;
}
while(sum < 0) {
sum += mod;
}
cout<<(sum+mod)%mod<<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5656kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5644kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 5656kb
input:
10
output:
823950739
result:
wrong answer 1st numbers differ - expected: '997920', found: '823950739'