QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#352899 | #6736. Alice and Bob | monster7000 | RE | 43ms | 25108kb | C++20 | 1.1kb | 2024-03-13 17:45:48 | 2024-03-13 17:45:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mod=998244353;
const int N=5e6+10;
int ac[N];
int inv[N];
int qmi(int a,int b)
{
int res=1;
a%=mod;
while(b>0)
{
if(b&1)res=(res*a)%mod;
b>>=1;
a=(a*a)%mod;
}
return res%mod;
}
void ca(int n)
{
ac[0]=1;
inv[0]=1;
for(int i=1;i<=n;i++)
{
ac[i]=ac[i-1]*i%mod;
ac[i]=(ac[i]+mod)%mod;
// cout<<i<<endl;
}
inv[n-1]=qmi(ac[n-1],mod-2);
for(int i=n-2;i>=1;i--)
{
inv[i]=inv[i+1]*(i+1)%mod;
}
}
int a(int n,int m)
{
int aa=1;
for(int i=n;m>=1;i--,m--)
{
aa=aa%mod*i%mod;
aa=(aa+mod)%mod;
}
// cout<<"aa:"<<aa<<endl;
return (aa+mod)%mod;
}
signed main()
{
int n;
cin>>n;
ca(n);
//for(int i=1;i<=4;i++)cout<<ac[i]<<endl;
int ans=0;
for(int i=1;i*2<=n+1;i++)
{
// cout<<"a[i] "<<ac[n-i]<<" "<<ac[n-i+1]<<endl;
int tt=ac[n-i]%mod*inv[n-2*i+1]%mod;
// cout<<"i2:"<<tt<<endl;
tt=(tt+mod)%mod;
tt=tt*ac[n-i]%mod;
tt=(tt+mod)%mod;
// cout<<"i:"<<tt<<endl;
ans=(ans+tt)%mod;
ans=(ans+mod)%mod;
}
cout<<(ans+mod)%mod<<endl;;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5672kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5688kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5704kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 1ms
memory: 5652kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 0ms
memory: 5656kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 1ms
memory: 5536kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 0ms
memory: 5580kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 1ms
memory: 5536kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 1ms
memory: 5740kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 43ms
memory: 25108kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: -100
Runtime Error
input:
7579013