QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287475#5. 在线 O(1) 逆元acwing_gza70 ✓1321ms394444kbC++14253b2023-12-20 17:10:082023-12-20 17:10:08

Judging History

你现在查看的是测评时间为 2023-12-20 17:10:08 的历史记录

  • [2024-11-05 21:56:06]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5360ms
  • 内存:394528kb
  • [2023-12-20 17:10:08]
  • 评测
  • 测评结果:70
  • 用时:1321ms
  • 内存:394444kb
  • [2023-12-20 17:10:08]
  • 提交

answer

#include "inv.h"
const int N=1e8+10;
int mod;
int a[N];
void init(int p)
{
	mod=p;
	a[0]=a[1]=1;
	for(int i=2;i<N;i++) a[i]=mod-1ll*(mod/i)*a[mod%i]%mod;
}
int inv(int x)
{
	if (x<N) return a[x];
	return mod-1ll*(mod/x)*inv(mod%x)%mod;
}

Details

Test #1:

score: 30
Accepted
time: 826ms
memory: 394244kb

Test #2:

score: 40
Accepted
time: 1321ms
memory: 394444kb

Test #3:

score: 0
Time Limit Exceeded