QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#815731 | #5. 在线 O(1) 逆元 | _tqx | 60 | 5281ms | 3884kb | C++17 | 247b | 2024-12-15 16:46:28 | 2024-12-15 16:46:28 |
Judging History
answer
#include<utility>
#include"inv.h"
int p;
void init(int p0){p=p0;}
std::pair<int,int>exgcd(int a,int b){
if(!b)return{1,0};
auto[x,y]=exgcd(b,a%b);
return{y,x-a/b*y};
}
int inv(int x){
auto[i,_]=exgcd(x,p);
return i<0?i+p:i;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 11ms
memory: 3864kb
Test #2:
score: 20
Accepted
time: 1057ms
memory: 3884kb
Test #3:
score: 30
Accepted
time: 5281ms
memory: 3728kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded