QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209310 | #5. 在线 O(1) 逆元 | fstqwq | 100 ✓ | 5273ms | 394508kb | C++14 | 369b | 2023-10-10 13:52:28 | 2024-11-05 21:53:14 |
Judging History
answer
const int mod = 998244353;
const int pre = 1e8;
int a[pre];
void init(int p) {
a[0] = a[1] = 1;
for (int i = 2; i < pre; i++) {
a[i] = 1ll * (mod - mod / i) * a[mod % i] % mod;
}
}
int inv(int x) {
int ret = 1;
while (x >= pre) {
ret = 1ll * ret * (mod - mod / x) % mod;
x = mod % x;
}
ret = 1ll * ret * a[x] % mod;
return ret;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 708ms
memory: 394312kb
Test #2:
score: 20
Accepted
time: 1155ms
memory: 394508kb
Test #3:
score: 30
Accepted
time: 3001ms
memory: 394400kb
Test #4:
score: 20
Accepted
time: 4399ms
memory: 394500kb
Test #5:
score: 20
Accepted
time: 5273ms
memory: 394308kb