QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287476#5. 在线 O(1) 逆元acwing_gza100 ✓5472ms394508kbC++14262b2023-12-20 17:11:132024-11-05 21:56:06

Judging History

This is the latest submission verdict.

  • [2024-11-05 21:56:06]
  • 管理员手动重测本题所有提交记录
  • Verdict: 100
  • Time: 5472ms
  • Memory: 394508kb
  • [2023-12-20 17:11:13]
  • Judged
  • Verdict: 70
  • Time: 1327ms
  • Memory: 394312kb
  • [2023-12-20 17:11:13]
  • Submitted

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(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;
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 808ms
memory: 394508kb

Test #2:

score: 20
Accepted
time: 1262ms
memory: 394292kb

Test #3:

score: 30
Accepted
time: 3178ms
memory: 394500kb

Test #4:

score: 20
Accepted
time: 4560ms
memory: 394504kb

Test #5:

score: 20
Accepted
time: 5472ms
memory: 394352kb