QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#798239 | #5. 在线 O(1) 逆元 | zzafanti | 80 | 5271ms | 394556kb | C++23 | 333b | 2024-12-04 09:59:18 | 2024-12-04 09:59:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using E=long long;
const int Lim=5e7;
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){
if(x<=Lim) return Inv[x];
E t=mod/x;
return (mod-t)*inv(mod-x*t)%mod;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 604ms
memory: 394556kb
Test #2:
score: 20
Accepted
time: 1226ms
memory: 394540kb
Test #3:
score: 30
Accepted
time: 3483ms
memory: 394428kb
Test #4:
score: 20
Accepted
time: 5271ms
memory: 394544kb
Test #5:
score: 0
Time Limit Exceeded