QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#268022 | #5. 在线 O(1) 逆元 | David713 | 80 | 5160ms | 161428kb | C++14 | 404b | 2023-11-27 22:55:47 | 2024-11-05 21:55:40 |
Judging History
answer
#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 1e8;
typedef long long ll;
int invv[N];
void init(int p)
{
invv[0] = invv[1] = 1;
for (int i = 2; i <= 4e7; i++) invv[i] = (1ll * (mod - mod / i) * invv[mod % i]) % mod;
}
int inv(int x)
{
if (x <= 4e7) return invv[x];
return (1ll * (mod - mod / x) * (ll)(inv(mod % x))) % mod;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 361ms
memory: 161032kb
Test #2:
score: 20
Accepted
time: 966ms
memory: 160228kb
Test #3:
score: 30
Accepted
time: 3331ms
memory: 161428kb
Test #4:
score: 20
Accepted
time: 5160ms
memory: 160688kb
Test #5:
score: 0
Time Limit Exceeded