QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534328#5. 在线 O(1) 逆元surgutti0 985ms394500kbC++14351b2024-08-27 02:41:462024-11-05 22:03:20

Judging History

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

  • [2024-11-05 22:03:20]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:985ms
  • 内存:394500kb
  • [2024-08-27 02:41:46]
  • 评测
  • 测评结果:0
  • 用时:861ms
  • 内存:394512kb
  • [2024-08-27 02:41:46]
  • 提交

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 - mod / i * inverse[mod % i] % mod) % mod;
}

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

Details


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 945ms
memory: 394368kb

Test #2:

score: 0
Wrong Answer
time: 985ms
memory: 394500kb

Test #3:

score: 0
Wrong Answer
time: 965ms
memory: 394372kb

Test #4:

score: 0
Wrong Answer
time: 977ms
memory: 394412kb

Test #5:

score: 0
Wrong Answer
time: 931ms
memory: 394252kb