QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208970 | #5. 在线 O(1) 逆元 | Williamxzh | 70 | 1114ms | 3816kb | C++14 | 418b | 2023-10-09 22:42:04 | 2023-10-09 22:42:06 |
Judging History
answer
#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
Test #1:
score: 30
Accepted
time: 12ms
memory: 3672kb
Test #2:
score: 40
Accepted
time: 1114ms
memory: 3816kb
Test #3:
score: 0
Time Limit Exceeded