QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798242#5. 在线 O(1) 逆元zzafanti0 0ms0kbC++23570b2024-12-04 10:06:422024-12-04 10:06:44

Judging History

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

  • [2024-12-04 10:06:44]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-12-04 10:06:42]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
using E=long long;

const int Lim=1e8;
E Inv[Lim+1];
const E mod=998244353;
const __int128 brt=((__int128)1<<64)/mod;

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;
  E now=(mod-t)*inv(mod-x*t);
  now=now-mod*((brt*now)>>64);
  if(now>=mod) now-=mod;
  return now;
}

#ifdef zzafanti

int main(){
  init(mod);
  cout<<inv(23214153)<<endl;
  return 0;
}

#endif // zzafanti

Details


Pretests


Final Tests

Test #1:

score: 0
Memory Limit Exceeded

Test #2:

score: 0
Memory Limit Exceeded

Test #3:

score: 0
Memory Limit Exceeded

Test #4:

score: 0
Memory Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded