QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402706 | #6736. Alice and Bob | altaires1# | TL | 0ms | 0kb | C++14 | 667b | 2024-05-01 11:20:16 | 2024-05-01 11:21:09 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int p=998244353;
const int N=1e7+5;
int fact[N],infact[N];
int qmi(int m,int k)
{
int res=1%p,t=m;
while(k)
{
if(k&1)res=res*t%p;
t=t*t%p;
k>>=1;
}
return res;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int res=0;
int n;
cin>>n;
fact[0]=infact[0]=1;
for(int i=1;i<N;i++)
{
fact[i]=fact[i-1]*i%p;
infact[i]=infact[i-1]*qmi(i,p-2)%p;
}
for(int i=1;i<=n;i++)
{
if(n-i<i-1)continue;
res=(res+fact[n-i]*infact[i-1]%p*infact[n-i-i+1]%p*fact[i-1]%p*fact[n-i]%p)%p;
}
cout<<res<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1
output:
1