QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#534331#5. 在线 O(1) 逆元surgutti100 ✓5211ms394504kbC++14363b2024-08-27 02:43:392024-11-05 22:03:22

Judging History

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

  • [2024-11-05 22:03:22]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5211ms
  • 内存:394504kb
  • [2024-08-27 02:43:40]
  • 评测
  • 测评结果:100
  • 用时:5121ms
  • 内存:394516kb
  • [2024-08-27 02:43:39]
  • 提交

answer

#include "inv.h"

constexpr int N = 100000000 + 1;
constexpr int mod = 998244353;

int inverse[N];

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

int inv(int x) {
	if (x < N)
		return inverse[x];
	return mod - (long long) (mod / x) * inv(mod % x) % mod;
}

详细


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 602ms
memory: 394300kb

Test #2:

score: 20
Accepted
time: 1056ms
memory: 394392kb

Test #3:

score: 30
Accepted
time: 2912ms
memory: 394504kb

Test #4:

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

Test #5:

score: 20
Accepted
time: 5211ms
memory: 394380kb