QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#489182 | #5. 在线 O(1) 逆元 | qwef_ | 0 | 0ms | 0kb | C++14 | 409b | 2024-07-24 18:49:26 | 2024-11-05 22:02:19 |
Judging History
answer
#include "inv.h"
typedef long long ll;
const int N=1.27e8+114,p=998244353;
int a[N];
inline void add(int& a,int b){a=(a+b>=p?a+b-p:a+b);}
void init(int _){
a[1]=1;
for(int i=2;i<N;++i) a[i]=(ll)(p-p/i)*a[p%i]%p;
}
int inv(int x){
for(int i=1,j=x;;++i,add(j,x))
if(j<N){
int k=0,o=a[j];
do{
if(i&1) add(k,o);
o=(o>=499122177?o+o-p:o+o);
}while(i>>1);
return k;
}
}
Details
Pretests
Final Tests
Test #1:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
Test #3:
score: 0
Time Limit Exceeded
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded