QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#464892 | #5. 在线 O(1) 逆元 | ETO_leader | 100 ✓ | 5746ms | 393832kb | C++23 | 671b | 2024-07-06 15:43:14 | 2024-11-05 21:59:50 |
Judging History
answer
#include<vector>
#define cir(i,a,b) for(int i=a;i<b;++i)
using std::vector;
using ulint=unsigned long long;
static constexpr auto MOD=998244353;
static constexpr auto mx=100000007;
vector<unsigned> q(mx);
constexpr auto Inv(ulint x){
auto res=1ull;auto b=MOD-2;
while(b){
if(b&1) (res*=x)%=MOD;
(x*=x)%=MOD;b>>=1;
}
return res;
}
void init(int p){
q[0]=1;
cir(i,1,mx){
q[i]=(1ull*q[i-1]*i)%MOD;
}
auto iv=Inv(q[mx-1]);
for(auto i=mx-1;i;--i){
q[i]=(iv*q[i-1])%MOD;
iv=(1ull*iv*i)%MOD;
}
}
int inv(int x){
return x<mx?q[x]:MOD-(1ll)*(MOD/x)*inv(MOD%x)%MOD;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 766ms
memory: 393800kb
Test #2:
score: 20
Accepted
time: 1282ms
memory: 393756kb
Test #3:
score: 30
Accepted
time: 3260ms
memory: 393756kb
Test #4:
score: 20
Accepted
time: 4728ms
memory: 393756kb
Test #5:
score: 20
Accepted
time: 5746ms
memory: 393832kb