QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287477#5. 在线 O(1) 逆元acwing_gza70 ✓1333ms394208kbC++14264b2023-12-20 17:12:002023-12-20 17:12:01

Judging History

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

  • [2024-11-05 21:56:18]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:4982ms
  • 内存:394508kb
  • [2023-12-20 17:12:01]
  • 评测
  • 测评结果:70
  • 用时:1333ms
  • 内存:394208kb
  • [2023-12-20 17:12:00]
  • 提交

answer

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

Details

Test #1:

score: 30
Accepted
time: 780ms
memory: 394204kb

Test #2:

score: 40
Accepted
time: 1333ms
memory: 394208kb

Test #3:

score: 0
Time Limit Exceeded