QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188491#5. 在线 O(1) 逆元EnofTaiPeople0 846ms394504kbC++14504b2023-09-25 21:27:252024-11-05 21:52:30

Judging History

This is the latest submission verdict.

  • [2024-11-05 21:52:30]
  • 管理员手动重测本题所有提交记录
  • Verdict: 0
  • Time: 846ms
  • Memory: 394504kb
  • [2023-09-25 21:27:33]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2023-09-25 21:27:25]
  • Submitted

answer

#include<bits/stdc++.h>
#include "inv.h"
using namespace std;
using ll=long long;
const int N=1e8+8,M=998244353;
int nv[N];
void init(int p){
	int x;
	nv[0]=nv[1]=1;
	for(x=2;x<N;++x)
		nv[x]=ll(M-M/x)*nv[M%x]%M;
}
int sol(int d){
	if(d<N)return nv[d];
	if(d<M-d){
		return ll(M-M/d)*sol(M%d)%M;
	}else{
		d=M-d;
		return ll(M/d)*sol(M%d)%M;
	}
}
int inv(int x){
	ll res=1;
	while(x>=N){
		x<M-x?res=-res:x=M-x;
		res=res*(M/x)%M;
	}res=res*nv[x]%M;
	return res<0?res+M:res;
}

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
Wrong Answer
time: 846ms
memory: 394504kb

Test #5:

score: 0
Time Limit Exceeded