QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865893 | #5. 在线 O(1) 逆元 | snpmrnhlol | 30 | 2551ms | 3840kb | C++17 | 316b | 2025-01-22 05:51:03 | 2025-01-22 05:51:05 |
Judging History
answer
#include <bits/stdc++.h>
#include "inv.h"
using namespace std;
int p2;
int fastexp(int a, int b){
int r = 1;
while(b){
if(b&1)r = 1ll*r*a%p2;
a = 1ll*a*a%p2;
b/=2;
}
return r;
}
void init(int p){
p2 = p;
}
int inv(int x){
return fastexp(x, p2 - 2);
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 25ms
memory: 3840kb
Test #2:
score: 20
Accepted
time: 2551ms
memory: 3840kb
Test #3:
score: 0
Time Limit Exceeded
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded