QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287474#5. 在线 O(1) 逆元acwing_gza0 675ms394508kbC++14255b2023-12-20 17:09:362024-11-05 21:56:06

Judging History

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

  • [2024-11-05 21:56:06]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:675ms
  • 内存:394508kb
  • [2023-12-20 17:09:36]
  • 评测
  • 测评结果:0
  • 用时:824ms
  • 内存:394424kb
  • [2023-12-20 17:09:36]
  • 提交

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


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 655ms
memory: 394508kb

Test #2:

score: 0
Wrong Answer
time: 673ms
memory: 394296kb

Test #3:

score: 0
Wrong Answer
time: 675ms
memory: 394496kb

Test #4:

score: 0
Wrong Answer
time: 669ms
memory: 394328kb

Test #5:

score: 0
Wrong Answer
time: 662ms
memory: 394376kb