QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#241467 | #5. 在线 O(1) 逆元 | mfeitveer | 100 ✓ | 5165ms | 511692kb | C++14 | 421b | 2023-11-06 08:13:21 | 2024-11-05 21:54:57 |
Judging History
answer
#include "inv.h"
const int N = 130000010;
const int mod = 998244353;
typedef long long ll;
int Inv[N];
ll ask(ll x) {
ll res = 1;
while(x > 130000000)
res = res * (mod - mod / x) % mod, x = mod % x;
return res * Inv[x] % mod;
}
void init(int p) {
Inv[1] = 1;
for(int i = 2;i <= 130000000;i++)
Inv[i] = 1ll * (mod - mod / i) * Inv[mod % i] % mod;
}
int inv(int x) {
return ask(x);
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 821ms
memory: 511584kb
Test #2:
score: 20
Accepted
time: 1262ms
memory: 511692kb
Test #3:
score: 30
Accepted
time: 3257ms
memory: 511584kb
Test #4:
score: 20
Accepted
time: 4388ms
memory: 511504kb
Test #5:
score: 20
Accepted
time: 5165ms
memory: 511664kb