QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293463 | #5. 在线 O(1) 逆元 | iee | 70 ✓ | 1232ms | 394248kb | C++14 | 389b | 2023-12-29 10:34:31 | 2023-12-29 10:34:33 |
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) {
if (x < N) return v[x];
return P - 1ll * inv(P % x) * (P / x) % P;
}
Details
Test #1:
score: 30
Accepted
time: 665ms
memory: 394248kb
Test #2:
score: 40
Accepted
time: 1232ms
memory: 394200kb
Test #3:
score: 0
Time Limit Exceeded