QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#876815 | #5. 在线 O(1) 逆元 | atgc | 100 ✓ | 5366ms | 394504kb | C++14 | 529b | 2025-01-31 13:28:07 | 2025-01-31 13:28:08 |
Judging History
answer
// #include<bits/stdc++.h>
// using namespace std;
#include"inv.h"
const int maxn = 1e8+10,mod=998244353;
int inv_a[maxn];
void init(int){
inv_a[1]=1;for(int i=2;i<maxn;++i)inv_a[i]=(long)(mod-mod/i)*inv_a[mod%i]%mod;
}
int inv(int x){
long scal=1;
while(x>=maxn)(scal*=-mod/x)%=mod,x=mod%x;
return(scal+mod)*inv_a[x]%mod;
}
// signed main() {
// ios::sync_with_stdio(0),cin.tie(0);
// init(0);
// while(1){
// int z=rand()%mod+1;
// assert((long)z*inv(z)%mod == 1);
// cerr<<z;
// }
// }
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 806ms
memory: 394468kb
Test #2:
score: 20
Accepted
time: 1300ms
memory: 394480kb
Test #3:
score: 30
Accepted
time: 3064ms
memory: 394312kb
Test #4:
score: 20
Accepted
time: 4459ms
memory: 394504kb
Test #5:
score: 20
Accepted
time: 5366ms
memory: 394444kb