QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#464862 | #5. 在线 O(1) 逆元 | ETO_leader | 0 | 0ms | 0kb | C++23 | 572b | 2024-07-06 15:29:21 | 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 q[x];}
Details
Pretests
Final Tests
Test #1:
score: 0
Runtime Error
Test #2:
score: 0
Runtime Error
Test #3:
score: 0
Runtime Error
Test #4:
score: 0
Runtime Error
Test #5:
score: 0
Runtime Error