QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#191006 | #6736. Alice and Bob | Bbaka_# | RE | 10ms | 19312kb | C++20 | 1.1kb | 2023-09-29 16:41:31 | 2023-09-29 16:41:31 |
Judging History
answer
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;
// #define int long long
const int mod = 998244353;
const int maxn = 1e6 + 10;
ll f[maxn],g[maxn];
ll qpow(ll n, ll m)
{
n%=mod;
ll res = 1;
while(m)
{
if(m&1)
{
res = res*n%mod;
}
n = n*n%mod;
m>>=1;
}
return res;
}
void init(void)
{
f[0]=1;
for(int i=1;i<maxn;i++)
{
f[i]=f[i-1]*i%mod;
}
g[maxn-1]=qpow(f[maxn-1],mod-2);
for(int i=maxn-2;i>=1;i--)
{
g[i]=g[i+1]*(i+1)%mod;
}
}
ll C(int n, int m)
{
if(m==0||m==n)
{
return 1;
}
if(m<=0 || n < m)
{
return 0;
}
else
{
return f[n]*g[m]%mod*g[n-m]%mod;
}
}
signed main()
{
init();
int n;
cin >> n;
ll ans = 0;
for (int i = 1; i <= n; i++)
{
ans += C(n - i, i - 1) * f[i - 1] % mod * f[n - i] % mod;
ans %= mod;
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 10ms
memory: 19300kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 10ms
memory: 19312kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 7ms
memory: 19308kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 3ms
memory: 19228kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 9ms
memory: 19308kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 6ms
memory: 19220kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 10ms
memory: 19244kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 7ms
memory: 19220kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 10ms
memory: 19224kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 7ms
memory: 19276kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 7ms
memory: 19312kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 10ms
memory: 19312kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 10ms
memory: 19216kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: -100
Runtime Error
input:
1361956