QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798240#5. 在线 O(1) 逆元zzafanti80 5891ms394552kbC++23343b2024-12-04 10:00:512024-12-04 10:00:51

Judging History

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

  • [2024-12-04 10:00:51]
  • 评测
  • 测评结果:80
  • 用时:5891ms
  • 内存:394552kb
  • [2024-12-04 10:00:51]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
using E=long long;

const int Lim=5e7;
E Inv[Lim+1];
const E mod=998244353;

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

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

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 645ms
memory: 394424kb

Test #2:

score: 20
Accepted
time: 1254ms
memory: 394532kb

Test #3:

score: 30
Accepted
time: 3886ms
memory: 394492kb

Test #4:

score: 20
Accepted
time: 5891ms
memory: 394552kb

Test #5:

score: 0
Time Limit Exceeded