QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#534331 | #5. 在线 O(1) 逆元 | surgutti | 100 ✓ | 5211ms | 394504kb | C++14 | 363b | 2024-08-27 02:43:39 | 2024-11-05 22:03:22 |
Judging History
answer
#include "inv.h"
constexpr int N = 100000000 + 1;
constexpr int mod = 998244353;
int inverse[N];
void init(int p) {
inverse[1] = 1;
for (int i = 2; i < N; i++)
inverse[i] = mod - (long long) (mod / i) * inverse[mod % i] % mod;
}
int inv(int x) {
if (x < N)
return inverse[x];
return mod - (long long) (mod / x) * inv(mod % x) % mod;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 602ms
memory: 394300kb
Test #2:
score: 20
Accepted
time: 1056ms
memory: 394392kb
Test #3:
score: 30
Accepted
time: 2912ms
memory: 394504kb
Test #4:
score: 20
Accepted
time: 4251ms
memory: 394504kb
Test #5:
score: 20
Accepted
time: 5211ms
memory: 394380kb