QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287480 | #5. 在线 O(1) 逆元 | acwing_gza | 100 ✓ | 5812ms | 394540kb | C++14 | 262b | 2023-12-20 17:12:59 | 2024-11-05 21:56:22 |
Judging History
answer
#include "inv.h"
const int N=1e8;
int mod;
int a[N+7];
void init(int p)
{
mod=p;
a[0]=a[1]=1;
for(register int i=2;i<=N;i++) a[i]=mod-1ll*(mod/i)*a[mod%i]%mod;
}
int inv(int x)
{
if(x<=N) return a[x];
return mod-1ll*(mod/x)*inv(mod%x)%mod;
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 816ms
memory: 394520kb
Test #2:
score: 20
Accepted
time: 1299ms
memory: 394468kb
Test #3:
score: 30
Accepted
time: 3456ms
memory: 394524kb
Test #4:
score: 20
Accepted
time: 5134ms
memory: 394540kb
Test #5:
score: 20
Accepted
time: 5812ms
memory: 394340kb