QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#293458 | #5. 在线 O(1) 逆元 | iee | 100 ✓ | 5539ms | 394464kb | C++14 | 303b | 2023-12-29 10:29:44 | 2024-11-05 21:56:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 998244353, N = 1e8;
int v[N];
void init(int p) {
v[1] = 1;
for (int i = 2; i < N; i++) {
v[i] = P - 1ll * v[P % i] * (P / i) % P;
}
}
int inv(int x) {
if (x < N) return v[x];
return P - 1ll * inv(P % x) * (P / x) % P;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 656ms
memory: 394408kb
Test #2:
score: 20
Accepted
time: 1125ms
memory: 394456kb
Test #3:
score: 30
Accepted
time: 3047ms
memory: 394308kb
Test #4:
score: 20
Accepted
time: 4538ms
memory: 394464kb
Test #5:
score: 20
Accepted
time: 5539ms
memory: 394332kb