QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209312 | #5. 在线 O(1) 逆元 | fstqwq | 100 ✓ | 5808ms | 42948kb | C++14 | 443b | 2023-10-10 13:53:36 | 2024-11-05 21:53:27 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
const int mod = 998244353;
const int pre = 1e7;
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) {
if (x < pre) return a[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: 49ms
memory: 42948kb
Test #2:
score: 20
Accepted
time: 611ms
memory: 42840kb
Test #3:
score: 30
Accepted
time: 2889ms
memory: 42804kb
Test #4:
score: 20
Accepted
time: 4644ms
memory: 42884kb
Test #5:
score: 20
Accepted
time: 5808ms
memory: 42840kb