QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640621 | #5. 在线 O(1) 逆元 | Yu_mx | 30 | 2201ms | 3880kb | C++14 | 221b | 2024-10-14 14:49:39 | 2024-11-05 22:05:21 |
Judging History
answer
#include"inv.h"
int mod;
void init(int p){
mod = p;
}
int inv(int x){
int p = mod;
int k = p-2;
int res = 1%p;
while(k){
if(k&1) res = 1LL*res*x%p;
k >>= 1;
x = 1LL*x*x%p;
}
return res;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 22ms
memory: 3732kb
Test #2:
score: 20
Accepted
time: 2201ms
memory: 3880kb
Test #3:
score: 0
Time Limit Exceeded
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded