QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395487 | #6736. Alice and Bob | frozen_wjl | WA | 701ms | 85896kb | C++23 | 775b | 2024-04-21 15:18:53 | 2024-04-21 15:18:53 |
Judging History
answer
#include<cmath>
#include<iostream>
#define mod 998244353
#define ll long long
#define N 10000005
using namespace std;
ll fac[N],inv1[N];
ll inv(ll t)
{
return t == 1 ? 1 : (mod - mod / t) * inv(mod % t) % mod;
}
void init()
{
int n = (N - 4)/2;
fac[0] = 1;
inv1[0] = 1;
for (int i = 1;i <= n;++i)
fac[i] = fac[i - 1] * i % mod, inv1[i] = inv(i) * inv1[i - 1] % mod;
inv1[n] = inv(fac[n]);
}
ll A(ll a, ll b)
{
ll ret = 0;
if (b >= a)
return fac[a];
return fac[a] * inv1[a - b] % mod;
}
int main()
{
int n;
ll ans = 0;
cin >> n;
init();
for (int i = 0;i < n;++i)
{
if (n - 1 - i < i)
break;
else ans = (ans + A(n - 1 - i, i) * A(n - 1 - i, n - 1 - i) % mod) % mod;
}
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 699ms
memory: 84372kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 689ms
memory: 83988kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 685ms
memory: 85068kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 694ms
memory: 84236kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 686ms
memory: 84184kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 701ms
memory: 84496kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 685ms
memory: 85628kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 684ms
memory: 84596kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 689ms
memory: 84176kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 693ms
memory: 85144kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 697ms
memory: 84884kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 682ms
memory: 83660kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 690ms
memory: 85896kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: 0
Accepted
time: 696ms
memory: 84996kb
input:
1361956
output:
617368199
result:
ok 1 number(s): "617368199"
Test #15:
score: -100
Wrong Answer
time: 695ms
memory: 85144kb
input:
7579013
output:
637920959
result:
wrong answer 1st numbers differ - expected: '827172636', found: '637920959'