QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#287475 | #5. 在线 O(1) 逆元 | acwing_gza | 100 ✓ | 5360ms | 394528kb | C++14 | 253b | 2023-12-20 17:10:08 | 2024-11-05 21:56:06 |
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;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 734ms
memory: 394528kb
Test #2:
score: 20
Accepted
time: 1209ms
memory: 394524kb
Test #3:
score: 30
Accepted
time: 2991ms
memory: 394460kb
Test #4:
score: 20
Accepted
time: 4359ms
memory: 394376kb
Test #5:
score: 20
Accepted
time: 5360ms
memory: 394324kb