QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#241464 | #5. 在线 O(1) 逆元 | mfeitveer | 100 ✓ | 5967ms | 394388kb | C++14 | 382b | 2023-11-06 08:05:44 | 2023-11-06 08:05:45 |
Judging History
answer
#include "inv.h"
const int N = 100000010;
const int mod = 998244353;
typedef long long ll;
int Inv[N];
ll ask(ll x) {
return (x <= 100000000 ? Inv[x] : (mod - mod / x) * ask(mod % x) % mod);
}
void init(int p) {
Inv[1] = 1;
for(int i = 2;i <= 100000000;i++)
Inv[i] = 1ll * (mod - mod / i) * Inv[mod % i] % mod;
}
int inv(int x) {
return ask(x);
}
詳細信息
Test #1:
score: 30
Accepted
time: 707ms
memory: 394388kb
Test #2:
score: 40
Accepted
time: 1187ms
memory: 394140kb
Test #3:
score: 30
Accepted
time: 5967ms
memory: 394076kb