QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#798232 | #5. 在线 O(1) 逆元 | zzafanti | 80 | 5169ms | 160156kb | C++23 | 306b | 2024-12-04 09:55:50 | 2024-12-04 09:55:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using E=long long;
const int Lim=2e7;
E Inv[Lim+1],mod;
void init(int p){
Inv[1]=1;
mod=p;
for(int i=2; i<=Lim; i++){
Inv[i]=(mod-mod/i)*Inv[mod%i]%mod;
}
}
int inv(int x){
return x<=Lim?Inv[x]:(mod-mod/x)*inv(mod%x)%mod;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 185ms
memory: 160096kb
Test #2:
score: 20
Accepted
time: 836ms
memory: 160156kb
Test #3:
score: 30
Accepted
time: 3311ms
memory: 160056kb
Test #4:
score: 20
Accepted
time: 5169ms
memory: 159972kb
Test #5:
score: 0
Time Limit Exceeded