QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209321 | #5. 在线 O(1) 逆元 | fstqwq | 60 | 3899ms | 23440kb | C++14 | 443b | 2023-10-10 13:55:01 | 2024-11-05 21:53:38 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
const int mod = 998244353;
const int pre = 5e6;
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;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 33ms
memory: 23372kb
Test #2:
score: 20
Accepted
time: 787ms
memory: 23440kb
Test #3:
score: 30
Accepted
time: 3899ms
memory: 23424kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded