QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209311 | #5. 在线 O(1) 逆元 | fstqwq | 70 | 743ms | 42852kb | C++14 | 397b | 2023-10-10 13:53:07 | 2023-10-10 13:53:08 |
Judging History
answer
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
Test #1:
score: 30
Accepted
time: 72ms
memory: 42852kb
Test #2:
score: 40
Accepted
time: 743ms
memory: 42728kb
Test #3:
score: 0
Time Limit Exceeded