QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850094 | #5. 在线 O(1) 逆元 | mnbvcxz123 | 60 | 4258ms | 12668kb | C++23 | 491b | 2025-01-09 20:20:18 | 2025-01-09 20:20:19 |
Judging History
answer
#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
ll inver[1000005];
bool vis[1000005];
int xd(int a) {
if(a<=1000000 and vis[a])return inver[a];
if(a<=1000000)vis[a]=1;
if(a<=1000000)return a <= 1 ? a : inver[a]=mod - (long long)(mod/a) * xd(mod % a) % mod;
return mod - (long long)(mod/a) * xd(mod % a) % mod;
}
void init(int p){
inver[1]=1;
}
int inv(int x){
return xd(x);
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 13ms
memory: 12668kb
Test #2:
score: 20
Accepted
time: 871ms
memory: 12480kb
Test #3:
score: 30
Accepted
time: 4258ms
memory: 12668kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded