QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287474 | #5. 在线 O(1) 逆元 | acwing_gza | 0 | 824ms | 394424kb | C++14 | 255b | 2023-12-20 17:09:36 | 2023-12-20 17:09:36 |
Judging History
answer
#include "inv.h"
const int N=1e8+10;
int mod;
int a[N];
void init(int p)
{
mod=p;
a[0]=a[1]=1;
for(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
Test #1:
score: 0
Wrong Answer
time: 815ms
memory: 394424kb
Test #2:
score: 0
Wrong Answer
time: 784ms
memory: 394204kb
Test #3:
score: 0
Wrong Answer
time: 824ms
memory: 394116kb