QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#798240 | #5. 在线 O(1) 逆元 | zzafanti | 80 | 5891ms | 394552kb | C++23 | 343b | 2024-12-04 10:00:51 | 2024-12-04 10:00:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using E=long long;
const int Lim=5e7;
E Inv[Lim+1];
const E mod=998244353;
void init(int p){
Inv[1]=1;
for(int i=2; i<=Lim; i++){
Inv[i]=(mod-mod/i)*Inv[mod%i]%mod;
}
}
int inv(int x){
if(x<=Lim) return Inv[x];
E t=mod/x;
return (mod-t)*inv(mod-x*t)%mod;
}
详细
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 645ms
memory: 394424kb
Test #2:
score: 20
Accepted
time: 1254ms
memory: 394532kb
Test #3:
score: 30
Accepted
time: 3886ms
memory: 394492kb
Test #4:
score: 20
Accepted
time: 5891ms
memory: 394552kb
Test #5:
score: 0
Time Limit Exceeded