QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798236#5. 在线 O(1) 逆元zzafanti80 5406ms316404kbC++23306b2024-12-04 09:57:012024-12-04 09:57:02

Judging History

This is the latest submission verdict.

  • [2024-12-04 09:57:02]
  • Judged
  • Verdict: 80
  • Time: 5406ms
  • Memory: 316404kb
  • [2024-12-04 09:57:01]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
using E=long long;

const int Lim=4e7;
E Inv[Lim+1],mod;

void init(int p){
  Inv[1]=1;
  mod=p;
  for(int i=2; i<=Lim; i++){
    Inv[i]=(mod-mod/i)*Inv[mod%i]%mod;
  }
}

int inv(int x){
  return x<=Lim?Inv[x]:(mod-mod/x)*inv(mod%x)%mod;
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 465ms
memory: 316404kb

Test #2:

score: 20
Accepted
time: 1085ms
memory: 316284kb

Test #3:

score: 30
Accepted
time: 3562ms
memory: 316364kb

Test #4:

score: 20
Accepted
time: 5406ms
memory: 316404kb

Test #5:

score: 0
Time Limit Exceeded