QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#217906 | #5. 在线 O(1) 逆元 | LGyxj | 60 | 3554ms | 42936kb | C++14 | 426b | 2023-10-17 15:53:16 | 2024-11-05 21:53:58 |
Judging History
answer
#include "inv.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1e7, mod = 998244353;
int invx[N];
int inv(int x) {
int res = 1;
while (x >= N) res = 1ll * res * (mod - mod / x) % mod, x = mod % x;
return 1ll * res * invx[x] % mod;
}
void init(int p) {
invx[1] = 1;
for (int i = 2; i < N; ++ i)
invx[i] = 1ll * (mod - mod / i) * invx[mod % i] % mod;
return;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 183ms
memory: 42932kb
Test #2:
score: 20
Accepted
time: 769ms
memory: 42828kb
Test #3:
score: 30
Accepted
time: 3554ms
memory: 42936kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded