QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287477 | #5. 在线 O(1) 逆元 | acwing_gza | 100 ✓ | 4982ms | 394508kb | C++14 | 264b | 2023-12-20 17:12:00 | 2024-11-05 21:56:18 |
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
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 654ms
memory: 394360kb
Test #2:
score: 20
Accepted
time: 1080ms
memory: 394312kb
Test #3:
score: 30
Accepted
time: 2820ms
memory: 394316kb
Test #4:
score: 20
Accepted
time: 4105ms
memory: 394380kb
Test #5:
score: 20
Accepted
time: 4982ms
memory: 394508kb