QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624879#5. 在线 O(1) 逆元dww_1337100 ✓5615ms394540kbC++14327b2024-10-09 16:48:302024-11-05 22:04:59

Judging History

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

  • [2024-11-05 22:04:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5615ms
  • 内存:394540kb
  • [2024-10-09 16:48:32]
  • 评测
  • 测评结果:100
  • 用时:5421ms
  • 内存:394524kb
  • [2024-10-09 16:48:30]
  • 提交

answer

#include "inv.h"

const int P = 998244353;
const int N = 1e8 + 5;
int invv[N];

void init(int p)
{
	invv[1] = 1;
	for (int i = 2; i <= N; i ++ )
	{
		invv[i] = p - 1ll*(p / i) * invv[p % i] % p;
	}
}

int inv(int x)
{
	if(x < N){
		return invv[x];
	} else {
		return P-1ll*(P / x) * inv(P % x) % P;
	}
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 820ms
memory: 394340kb

Test #2:

score: 20
Accepted
time: 1328ms
memory: 394540kb

Test #3:

score: 30
Accepted
time: 3333ms
memory: 394388kb

Test #4:

score: 20
Accepted
time: 4658ms
memory: 394340kb

Test #5:

score: 20
Accepted
time: 5615ms
memory: 394340kb