QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188498#5. 在线 O(1) 逆元EnofTaiPeople100 ✓5578ms394412kbC++14367b2023-09-25 21:29:432023-09-25 21:29:44

Judging History

你现在查看的是测评时间为 2023-09-25 21:29:44 的历史记录

  • [2024-11-05 21:52:45]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5074ms
  • 内存:394448kb
  • [2023-09-25 21:29:44]
  • 评测
  • 测评结果:100
  • 用时:5578ms
  • 内存:394412kb
  • [2023-09-25 21:29:43]
  • 提交

answer

#include<bits/stdc++.h>
#include "inv.h"
using namespace std;
using ul=unsigned 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]=ul(M-M/x)*nv[M%x]%M;
}
int inv(int x){
	ul res=1;
	while(x>=N){
		x<M-x?res=M-res:x=M-x;
		res=res*(M/x)%M,x=M%x;
	}res=res*nv[x]%M;
	return res;
}

Details

Test #1:

score: 30
Accepted
time: 685ms
memory: 394412kb

Test #2:

score: 40
Accepted
time: 1191ms
memory: 394284kb

Test #3:

score: 30
Accepted
time: 5578ms
memory: 394176kb