QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209166 | #6736. Alice and Bob | luhanning | TL | 0ms | 0kb | C++14 | 848b | 2023-10-10 11:01:06 | 2023-10-10 11:01:07 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e7 + 10;
const int mod = 998244353;
int n, m, k;
string s1, s2;
int h[N], idx, ne[N];
vector<int> pa;
double a, b;
int infact[N];
int fact[N];
int qmi(int a,int k,int p)
{
int res=1;
while(k){
if(k&1) res=res*a%p;
a=a*a%p;
k>>=1;
}
return res;
}
void solve() {
cin >> n;
int ans = 0;
for (int i = 1; i <= n+1; i++) {
if (n - i >= i - 1) {
int t1=fact[n-i]%mod;
int t2=fact[n-i]*infact[n-i-(i-1)]%mod;
ans=(ans+(t1*t2)%mod)%mod;
}
}
//cout<<fact[3]<<endl;
cout << ans << endl;
}
signed main() {
int t = 1;
fact[0]=infact[0]=1;
for(int i=1;i<N;i++)
{
fact[i]=fact[i-1]*i%mod;
infact[i]=infact[i-1]*qmi(i,mod-2,mod)%mod;
}
//cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1
output:
1