QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#287481#5. 在线 O(1) 逆元acwing_gza100 ✓5613ms394508kbC++11262b2023-12-20 17:13:342024-11-05 21:56:23

Judging History

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

  • [2024-11-05 21:56:23]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5613ms
  • 内存:394508kb
  • [2023-12-20 17:13:36]
  • 评测
  • 测评结果:70
  • 用时:1344ms
  • 内存:394312kb
  • [2023-12-20 17:13:34]
  • 提交

answer

#include "inv.h"
const int N=1e8;
int mod;
int a[N+7];
void init(int p)
{
	mod=p;
	a[0]=a[1]=1;
	for(register 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;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 780ms
memory: 394372kb

Test #2:

score: 20
Accepted
time: 1244ms
memory: 394500kb

Test #3:

score: 30
Accepted
time: 3193ms
memory: 394432kb

Test #4:

score: 20
Accepted
time: 4652ms
memory: 394372kb

Test #5:

score: 20
Accepted
time: 5613ms
memory: 394508kb