QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#208971#5. 在线 O(1) 逆元Williamxzh60 5678ms3908kbC++14508b2023-10-09 22:43:082024-11-05 21:53:02

Judging History

This is the latest submission verdict.

  • [2024-11-05 21:53:02]
  • 管理员手动重测本题所有提交记录
  • Verdict: 60
  • Time: 5678ms
  • Memory: 3908kb
  • [2023-10-09 22:43:10]
  • Judged
  • Verdict: 70
  • Time: 1159ms
  • Memory: 3792kb
  • [2023-10-09 22:43:08]
  • Submitted

answer

#pragma GCC optimize("O2,O3,Ofast,inline,unroll-loops")
#pragma GCC target("avx2,sse4")
#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
const __uint128_t brt=((__uint128_t)1<<64)/mod;
void init(int p){

}
int inv(int x){
    int b=mod-2;long long ans=1ll,a=1ll*x;
    while(b){
        if(b&1){ans*=a,ans-=mod*(brt*ans>>64);while(ans>=mod) ans-=mod;}
        a*=a,a-=mod*(brt*a>>64);while(a>=mod) a-=mod;
        b>>=1;
    }
    return int(ans);
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 9ms
memory: 3908kb

Test #2:

score: 20
Accepted
time: 1136ms
memory: 3684kb

Test #3:

score: 30
Accepted
time: 5678ms
memory: 3840kb

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded