QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293450#5. 在线 O(1) 逆元iee100 ✓5347ms394516kbC++17303b2023-12-29 10:21:002024-11-05 21:56:34

Judging History

This is the latest submission verdict.

  • [2024-11-05 21:56:34]
  • 管理员手动重测本题所有提交记录
  • Verdict: 100
  • Time: 5347ms
  • Memory: 394516kb
  • [2023-12-29 10:21:01]
  • Judged
  • Verdict: 70
  • Time: 1426ms
  • Memory: 394312kb
  • [2023-12-29 10:21:00]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e8, P = 998244353;
int v[N];
void init(int p) {
	v[1] = 1;
	for (int i = 2; i < N; i++) {
		v[i] = 1ll * v[P % i] * (P - P / i) % P;
	}
}
int inv(int x) {
	if (x < N) return v[x];
	return 1ll * inv(P % x) * (P - P / x) % P;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 649ms
memory: 394308kb

Test #2:

score: 20
Accepted
time: 1126ms
memory: 394516kb

Test #3:

score: 30
Accepted
time: 3042ms
memory: 394508kb

Test #4:

score: 20
Accepted
time: 4402ms
memory: 394324kb

Test #5:

score: 20
Accepted
time: 5347ms
memory: 394400kb