QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#489190#5. 在线 O(1) 逆元qwef_60 4395ms515536kbC++23563b2024-07-24 18:52:032024-11-05 22:02:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 22:02:31]
  • 管理员手动重测本题所有提交记录
  • 测评结果:60
  • 用时:4395ms
  • 内存:515536kb
  • [2024-07-24 18:52:03]
  • 评测
  • 测评结果:70
  • 用时:1566ms
  • 内存:515504kb
  • [2024-07-24 18:52:03]
  • 提交

answer

//#include <bits/stdc++.h>
#include "inv.h"
typedef long long ll;
const int N=1.31e8+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;
		}
}
//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: 807ms
memory: 515468kb

Test #2:

score: 20
Accepted
time: 1522ms
memory: 515472kb

Test #3:

score: 30
Accepted
time: 4395ms
memory: 515536kb

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded