QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209310 | #5. 在线 O(1) 逆元 | fstqwq | 70 ✓ | 1345ms | 394416kb | C++14 | 369b | 2023-10-10 13:52:28 | 2023-10-10 13:52:30 |
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
Test #1:
score: 30
Accepted
time: 713ms
memory: 394196kb
Test #2:
score: 40
Accepted
time: 1345ms
memory: 394416kb
Test #3:
score: 0
Time Limit Exceeded