QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397295 | #6736. Alice and Bob | Yammer | RE | 1ms | 3728kb | C++17 | 962b | 2024-04-23 21:35:37 | 2024-04-23 21:35:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define PII pair<int, int>
typedef long long ll;
const int N = 2e5 + 10, MOD = 998244353;
int fac[N], invfac[N];
ll qmi(int a, int b){
ll ans = 1;
while(b){
if(b & 1) ans = 1ll * ans * a % MOD;
a = 1ll * a * a % MOD;
b >>= 1;
}
return ans;
}
int main(){
int n; cin >> n;
fac[0] = 1;
for(int i = 1; i <= n; ++ i){
fac[i] = 1ll * fac[i - 1] * i % MOD;
}
invfac[n] = qmi(fac[n], MOD - 2);
for(int i = n; i >= 1; -- i){
invfac[i - 1] = 1ll * invfac[i] * i % MOD;
}
ll ans = 0;
for(int i = 1; i <= n; ++ i){
if(n - i >= i - 1){
ans = (ans + 1ll * fac[n - i] * fac[n - i] % MOD * invfac[n - i - i + 1]) % MOD;
}
}
// cout << (1ll * fac[5] * invfac[3] % MOD * invfac[2] % MOD + MOD) % MOD << '\n';
cout << 1ll * (ans + MOD) % MOD;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3724kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
10
output:
997920
result:
ok 1 number(s): "997920"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
100
output:
188898954
result:
ok 1 number(s): "188898954"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
4
output:
10
result:
ok 1 number(s): "10"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
8
output:
12336
result:
ok 1 number(s): "12336"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
16
output:
373118483
result:
ok 1 number(s): "373118483"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
32
output:
314585464
result:
ok 1 number(s): "314585464"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
64
output:
627827331
result:
ok 1 number(s): "627827331"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
128
output:
828497685
result:
ok 1 number(s): "828497685"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
256
output:
65697890
result:
ok 1 number(s): "65697890"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
512
output:
854187619
result:
ok 1 number(s): "854187619"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1024
output:
513823539
result:
ok 1 number(s): "513823539"
Test #14:
score: -100
Runtime Error
input:
1361956