QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#409232 | #6736. Alice and Bob | yerkindar | WA | 1ms | 7784kb | C++14 | 995b | 2024-05-11 20:43:37 | 2024-05-11 20:43:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
int n,m,t,k;
const int N=1e7+5,mo=998244353;
typedef pair<int,int> PII;
int frac[5000005],inv[5000005],jie[5000005];
const int p=998244353;
ll mi(ll x,ll y)
{
int res=1;
for(;y;y>>=1,x=(ll)x*x%mo)
if(y&1) res=(ll)res*x%mo;
return res;
}
ll C(int x,int y)
{
if(x<y) return 0;
return (ll)frac[x]*inv[y]%mo*inv[x-y]%mo;
}
void init()
{
int i,j;
frac[0]=1;
for(i=1;i<=n;i++) frac[i]=(ll)frac[i-1]*i%mo;
inv[n]=mi(frac[n],mo-2);
for(i=n-1;i>=0;--i) inv[i]=(ll)inv[i+1]*(i+1)%mo;
}
void solve(){
cin>>n;
init();
long long ans=0;
for(int i=1;i<=n;i++){
if(n-i<i-1){
break;
}
ans=(ans+(ll)(C(n-i,i-1)*frac[i-1]*frac[n-i])%mo)%mo;
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
int __=1;
//cin>>__;
//init();
while(__--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7780kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7700kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 7784kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 7764kb
input:
100
output:
41709352
result:
wrong answer 1st numbers differ - expected: '188898954', found: '41709352'