QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#356298 | #6736. Alice and Bob | star_xiao# | WA | 1ms | 8048kb | C++23 | 1.0kb | 2024-03-17 17:23:09 | 2024-03-17 17:23:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//int n;
#define int long long
const int mod=998244353;
const int N=1e7+10;
int sum[N];
int fac[N],infac[N];
int n;
int qmi(int a,int b)
{
int res=1ll;
while(b)
{
if(b&1) res=res*a%mod;
b>>=1;
a=a*a%mod;
}
return res%mod;
}
void init()
{
fac[0]=infac[0]=1ll;
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;
scanf("%lld",&n);
sum[0]=1ll;
init();
//cout<<C(3,2);
for(int i=1;i<=n;i++)
{
//ans=ans*i%mod;
sum[i]=sum[i-1]*i%mod;
sum[i]=(sum[i]+mod)%mod;
}
//sum[0]=0;
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';
}
printf("%lld\n",(ans+mod)%mod);
}
signed main()
{
//ios::sync_with_stdio(false);
//cin.tie(0),cout.tie(0);
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 8048kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 8000kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 8004kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 7924kb
input:
100
output:
263296435
result:
wrong answer 1st numbers differ - expected: '188898954', found: '263296435'