QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#489171 | #5. 在线 O(1) 逆元 | qwef_ | 30 | 2519ms | 499952kb | C++14 | 503b | 2024-07-24 18:45:47 | 2024-11-05 22:01:58 |
Judging History
answer
//#include <bits/stdc++.h>
#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=a[j];
for(;--i;add(k,a[j]));
return k;
}
}
//int main(){
// init(998244353);
// int x;
// std::cin >> x;
// std::cout << query(x) << std::endl;
// return 0;
//}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 1026ms
memory: 499952kb
Test #2:
score: 20
Accepted
time: 2519ms
memory: 499784kb
Test #3:
score: 0
Time Limit Exceeded
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded