QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#624864 | #5. 在线 O(1) 逆元 | BlackPanda | 100 ✓ | 5505ms | 394388kb | C++14 | 327b | 2024-10-09 16:46:11 | 2024-10-09 16:46:12 |
Judging History
answer
#include "inv.h"
const int P = 998244353;
const int N = 1e8 + 5;
int invv[N];
void init(int p)
{
invv[1] = 1;
for (int i = 2; i <= N; i ++ )
{
invv[i] = p - 1ll*(p / i) * invv[p % i] % p;
}
}
int inv(int x)
{
if(x < N){
return invv[x];
} else {
return P-1ll*(P / x) * inv(P % x) % P;
}
}
详细
Pretests
Final Tests
Test #1:
score: 30
Accepted
time: 709ms
memory: 394388kb
Test #2:
score: 40
Accepted
time: 1183ms
memory: 394320kb
Test #3:
score: 30
Accepted
time: 5505ms
memory: 394316kb