QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356263 | #6736. Alice and Bob | star_xiao# | WA | 1ms | 7748kb | C++14 | 973b | 2024-03-17 17:08:21 | 2024-03-17 17:08:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//int n;
const int N=1e7+10;
#define int long long
const int mod=998244353;
int sum[N];
int fac[N],infac[N];
int n;
int qmi(int a,int b)
{
int res=1;
while(b)
{
if(b&1) res=res*a%mod;
b>>=1;
a=a*a%mod;
}
return res%mod;
}
void init()
{
fac[0]=infac[0]=1ll;
for(int i=1;i<=n;i++)
{
fac[i]=fac[i-1]*i%mod;
infac[i]=infac[i-1]*qmi(i,mod-2)%mod;
}
}
int C(int a,int b)
{
return fac[b]*infac[a]%mod*infac[b-a]%mod;
}
void solve()
{
int ans=0;
cin>>n;
sum[0]=1ll;
init();
//cout<<C(3,2);
for(int i=1;i<=n;i++)
{
//ans=ans*i%mod;
sum[i]=sum[i-1]*i%mod;
}
//sum[0]=0;
ans=(sum[n-1])%mod;
for(int i=2;i<=n;i++)
{
ans=(ans+(C(i-1,n-i)%mod)*sum[i-1]%mod*sum[n-i]%mod)%mod;
//cout<<ans<<'\n';
}
cout<<(ans+mod)%mod;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7748kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5552kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5616kb
input:
10
output:
346339639
result:
wrong answer 1st numbers differ - expected: '997920', found: '346339639'