QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188498#5. 在线 O(1) 逆元EnofTaiPeople100 ✓5074ms394448kbC++14367b2023-09-25 21:29:432024-11-05 21:52:45

Judging History

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

  • [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;
}

详细


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 684ms
memory: 394448kb

Test #2:

score: 20
Accepted
time: 1112ms
memory: 394328kb

Test #3:

score: 30
Accepted
time: 2850ms
memory: 394328kb

Test #4:

score: 20
Accepted
time: 4150ms
memory: 394332kb

Test #5:

score: 20
Accepted
time: 5074ms
memory: 394332kb