QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356253 | #6736. Alice and Bob | star_xiao# | WA | 1ms | 7756kb | C++14 | 973b | 2024-03-17 17:05:06 | 2024-03-17 17:05:06 |
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]=1;
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]=1;
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=(ans+sum[n-1]+mod)%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)%mod;
//cout<<ans<<'\n';
}
cout<<ans%mod;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7756kb
input:
1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'