QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241570#5. 在线 O(1) 逆元Endline80 4935ms394524kbC++14407b2023-11-06 11:52:242024-11-05 21:55:11

Judging History

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

  • [2024-11-05 21:55:11]
  • 管理员手动重测本题所有提交记录
  • 测评结果:80
  • 用时:4935ms
  • 内存:394524kb
  • [2023-11-06 11:52:25]
  • 评测
  • 测评结果:100
  • 用时:5547ms
  • 内存:394392kb
  • [2023-11-06 11:52:24]
  • 提交

answer

#include<bits/stdc++.h>
#include"inv.h"
#define MAXN 100000002
using namespace std;
const int mod=998244353;
int now,Inv[MAXN];
int calc(int x)
{
	if(x<=now)return Inv[x];
	return 1ll*(mod-mod/x)*calc(mod%x)%mod;
}
void init(int p)
{
	Inv[1]=1,now=1;
	for(int i=2;i<=100000000;i++)
		Inv[i]=calc(i),now=i;	
}
int inv(int x)
{
	if(x<=mod/2)return calc(x);
	else return mod-calc(mod-x);
}

Details


Pretests


Final Tests

Test #1:

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

Test #2:

score: 20
Accepted
time: 1284ms
memory: 394376kb

Test #3:

score: 30
Accepted
time: 3068ms
memory: 394520kb

Test #4:

score: 20
Accepted
time: 4935ms
memory: 394524kb

Test #5:

score: 0
Time Limit Exceeded