QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208971 | #5. 在线 O(1) 逆元 | Williamxzh | 60 | 5678ms | 3908kb | C++14 | 508b | 2023-10-09 22:43:08 | 2024-11-05 21:53:02 |
Judging History
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