QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246040 | #6736. Alice and Bob | Colblue# | TL | 0ms | 0kb | C++14 | 1.0kb | 2023-11-10 15:47:41 | 2023-11-10 15:47:41 |
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N=1e7+10,mod=998244353;
ll qpw(ll a,ll n)
{
ll res=1;
a%=mod;
while(n)
{
if(n&1)
res=(res*a)%mod;
n>>=1;
a=(a*a)%mod;
}
return res;
}
ll fact[N],infact[N];
void init()
{
fact[0]=infact[0]=1;
for(int i=1;i<N;i++)
{
fact[i]=(fact[i-1]*i)%mod;
infact[i] =( infact[i-1]*qpw(i,mod-2))%mod;
}
}
ll C(int a,int b)
{
if(b>a)
return 0;
ll res=1;
res=((fact[a]*infact[a-b])%mod*infact[b])%mod;
return res;
}
int a[N];
void solve()
{
int n;
cin>>n;
ll res=0;
for(int i=1;i<=n;i++)
{
ll tmp= (C(n-i,i-1)* fact[i-1])%mod;
tmp= (tmp*fact[n-i])%mod;
res=(res+tmp)%mod;
}
cout<<res<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
init();
int T;
//cin>>T;
T=1;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1
output:
1