QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640621 | #5. 在线 O(1) 逆元 | Yu_mx | 70 | 2185ms | 3788kb | C++14 | 221b | 2024-10-14 14:49:39 | 2024-10-14 14:49:40 |
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: 30
Accepted
time: 22ms
memory: 3788kb
Test #2:
score: 40
Accepted
time: 2185ms
memory: 3668kb
Test #3:
score: 0
Time Limit Exceeded