QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534327#5. 在线 O(1) 逆元surguttiCompile Error//C++14373b2024-08-27 02:41:222024-11-05 22:03:16

Judging History

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

  • [2024-11-05 22:03:16]
  • 管理员手动重测本题所有提交记录
  • [2024-08-27 02:41:23]
  • 评测
  • [2024-08-27 02:41:22]
  • 提交

answer

#include "inv.h"

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

int inverse[N];

void init(int p) {
	assert(p == mod);

	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

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code: In function ‘void init(int)’:
answer.code:9:9: error: ‘assert’ was not declared in this scope
    9 |         assert(p == mod);
      |         ^~~~~~
answer.code:2:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    1 | #include "inv.h"
  +++ |+#include <cassert>
    2 |