QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293466 | #5. 在线 O(1) 逆元 | iee | 0 | 712ms | 394512kb | C++11 | 435b | 2023-12-29 10:41:32 | 2024-11-05 21:57:23 |
Judging History
answer
#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "inv.h"
using namespace std;
constexpr int N = 1e8;
int v[N], P;
void init(int p) {
P = p;
v[1] = 1;
for (int i = 2; i < N; i++) {
v[i] = P - 1ll * v[P % i] * (P / i) % P;
}
}
int inv(int x) {
int res = 1;
while (x >= N) {
res = P - 1ll * res * (P / x);
x = P % x;
}
return 1ll * res * v[x] % P;
}
Details
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 692ms
memory: 394512kb
Test #2:
score: 0
Wrong Answer
time: 676ms
memory: 394372kb
Test #3:
score: 0
Wrong Answer
time: 698ms
memory: 394428kb
Test #4:
score: 0
Wrong Answer
time: 695ms
memory: 394424kb
Test #5:
score: 0
Wrong Answer
time: 712ms
memory: 394512kb