QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850155 | #5. 在线 O(1) 逆元 | mnbvcxz123 | 60 | 4984ms | 91696kb | C++23 | 496b | 2025-01-09 20:56:45 | 2025-01-09 20:56:45 |
Judging History
answer
#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
ll inver[10000005];
bool vis[10000005];
int xd(int a) {
if(a<=10000000 and vis[a])return inver[a];
if(a<=10000000)vis[a]=1;
if(a<=10000000)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: 16ms
memory: 91688kb
Test #2:
score: 20
Accepted
time: 1212ms
memory: 91636kb
Test #3:
score: 30
Accepted
time: 4984ms
memory: 91696kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded