QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850082 | #5. 在线 O(1) 逆元 | mnbvcxz123 | 0 | 709ms | 448092kb | C++23 | 542b | 2025-01-09 20:12:25 | 2025-01-09 20:12:27 |
Judging History
answer
#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
ll exp(ll a, ll w){
ll ret=1;
a%=mod;
while(w){
if(w&1)ret=1ll*ret*a%mod;
a=1ll*a*a%mod;
w>>=1;
}
return ret;
}
ll inver[100000000];
int lst=1;
void init(int p){
inver[1]=1;
}
int inv(int x){
if(x>=1e8)return exp(x,mod-2);
while(lst<x){
inver[lst]=mod-1ll*(mod/lst)*inver[mod%lst]%mod;
++lst;
}
return inver[x];
}
Details
Pretests
Final Tests
Test #1:
score: 0
Memory Limit Exceeded
Test #2:
score: 0
Wrong Answer
time: 709ms
memory: 448092kb
Test #3:
score: 0
Wrong Answer
time: 390ms
memory: 263560kb
Test #4:
score: 0
Wrong Answer
time: 448ms
memory: 264444kb
Test #5:
score: 0
Wrong Answer
time: 300ms
memory: 187472kb