QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#839134 | #1089. Biological Software Utilities | WaterSun | AC ✓ | 11ms | 19360kb | C++14 | 1.4kb | 2025-01-01 12:08:12 | 2025-01-01 12:08:14 |
Judging History
answer
#include <bits/stdc++.h>
#define re register
#define int long long
#define Add(a,b) (((a) + (b)) % mod)
#define Mul(a,b) ((a) * (b) % mod)
#define chMul(a,b) (a = Mul(a,b))
using namespace std;
const int N = 1e6 + 10;
const int mod = 998244353;
int n;
int fac[N],infac[N];
inline int read(){
int r = 0,w = 1;
char c = getchar();
while (c < '0' || c > '9'){
if (c == '-') w = -1;
c = getchar();
}
while (c >= '0' && c <= '9'){
r = (r << 3) + (r << 1) + (c ^ 48);
c = getchar();
}
return r * w;
}
inline int qmi(int a,int b){
int res = 1;
while (b){
if (b & 1) chMul(res,a);
chMul(a,a); b >>= 1;
}
return res;
}
inline void init(int n){
fac[0] = 1;
for (re int i = 1;i <= n;i++) fac[i] = Mul(fac[i - 1],i);
infac[n] = qmi(fac[n],mod - 2);
for (re int i = n - 1;~i;i--) infac[i] = Mul(infac[i + 1],i + 1);
}
signed main(){
init(n = read());
if (n & 1) puts("0");
else if (n == 2) puts("1");
else{
int ans = 1,num = n / 2;
for (re int i = 0;i < num - 1;i++) chMul(ans,(n - 2 * i) * (n - 2 * i - 1) / 2 % mod);
// cerr << num << " " << ans << " ???\n";
chMul(ans,infac[num]);
// cerr << num << " " << ans << " ???\n";
if (num >= 2) chMul(ans,qmi(num,num - 2));
chMul(ans,qmi(4,num - 1)); printf("%lld",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5596kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5600kb
input:
3
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5824kb
input:
4
output:
12
result:
ok 1 number(s): "12"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5812kb
input:
7788
output:
178152092
result:
ok 1 number(s): "178152092"
Test #6:
score: 0
Accepted
time: 11ms
memory: 19308kb
input:
1000000
output:
178454094
result:
ok 1 number(s): "178454094"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
12346
output:
751958800
result:
ok 1 number(s): "751958800"
Test #8:
score: 0
Accepted
time: 4ms
memory: 19360kb
input:
999996
output:
690785929
result:
ok 1 number(s): "690785929"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
6
output:
720
result:
ok 1 number(s): "720"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
10
output:
30240000
result:
ok 1 number(s): "30240000"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
99
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
100
output:
934178078
result:
ok 1 number(s): "934178078"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
20
output:
245111072
result:
ok 1 number(s): "245111072"
Test #14:
score: 0
Accepted
time: 1ms
memory: 4244kb
input:
38745
output:
0
result:
ok 1 number(s): "0"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
3848
output:
928659530
result:
ok 1 number(s): "928659530"
Test #16:
score: 0
Accepted
time: 2ms
memory: 9068kb
input:
347835
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 4ms
memory: 7484kb
input:
234234
output:
745247398
result:
ok 1 number(s): "745247398"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
12
output:
818069491
result:
ok 1 number(s): "818069491"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
98
output:
648803799
result:
ok 1 number(s): "648803799"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
124
output:
159487965
result:
ok 1 number(s): "159487965"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
1024
output:
318674437
result:
ok 1 number(s): "318674437"
Test #22:
score: 0
Accepted
time: 8ms
memory: 12132kb
input:
524288
output:
495260023
result:
ok 1 number(s): "495260023"
Test #23:
score: 0
Accepted
time: 0ms
memory: 11672kb
input:
524289
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 10ms
memory: 19300kb
input:
999999
output:
0
result:
ok 1 number(s): "0"
Test #25:
score: 0
Accepted
time: 9ms
memory: 19264kb
input:
999997
output:
0
result:
ok 1 number(s): "0"