QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489171#5. 在线 O(1) 逆元qwef_30 2519ms499952kbC++14503b2024-07-24 18:45:472024-11-05 22:01:58

Judging History

This is the latest submission verdict.

  • [2024-11-05 22:01:58]
  • 管理员手动重测本题所有提交记录
  • Verdict: 30
  • Time: 2519ms
  • Memory: 499952kb
  • [2024-07-24 18:45:47]
  • Judged
  • Verdict: 70
  • Time: 1778ms
  • Memory: 499980kb
  • [2024-07-24 18:45:47]
  • Submitted

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;
//}

詳細信息


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