QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#815731#5. 在线 O(1) 逆元_tqx60 5281ms3884kbC++17247b2024-12-15 16:46:282024-12-15 16:46:28

Judging History

你现在查看的是最新测评结果

  • [2024-12-15 16:46:28]
  • 评测
  • 测评结果:60
  • 用时:5281ms
  • 内存:3884kb
  • [2024-12-15 16:46:28]
  • 提交

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