QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#798237 | #5. 在线 O(1) 逆元 | zzafanti | 80 | 5217ms | 238240kb | C++23 | 306b | 2024-12-04 09:57:51 | 2024-12-04 09:57:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using E=long long;
const int Lim=3e7;
E Inv[Lim+1],mod;
void init(int p){
Inv[1]=1;
mod=p;
for(int i=2; i<=Lim; i++){
Inv[i]=(mod-mod/i)*Inv[mod%i]%mod;
}
}
int inv(int x){
return x<=Lim?Inv[x]:(mod-mod/x)*inv(mod%x)%mod;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 301ms
memory: 238176kb
Test #2:
score: 20
Accepted
time: 878ms
memory: 238240kb
Test #3:
score: 30
Accepted
time: 3355ms
memory: 238100kb
Test #4:
score: 20
Accepted
time: 5217ms
memory: 238088kb
Test #5:
score: 0
Time Limit Exceeded