QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287477 | #5. 在线 O(1) 逆元 | acwing_gza | 70 ✓ | 1333ms | 394208kb | C++14 | 264b | 2023-12-20 17:12:00 | 2023-12-20 17:12:01 |
Judging History
answer
#include "inv.h"
const int N=1e8+7;
int mod;
int a[N];
void init(int p)
{
mod=p;
a[0]=a[1]=1;
for(register int i=2;i<1e8;i++) a[i]=mod-1ll*(mod/i)*a[mod%i]%mod;
}
int inv(int x)
{
if(x<1e8) return a[x];
return mod-1ll*(mod/x)*inv(mod%x)%mod;
}
Details
Test #1:
score: 30
Accepted
time: 780ms
memory: 394204kb
Test #2:
score: 40
Accepted
time: 1333ms
memory: 394208kb
Test #3:
score: 0
Time Limit Exceeded