QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624864#5. 在线 O(1) 逆元BlackPanda100 ✓5505ms394388kbC++14327b2024-10-09 16:46:112024-10-09 16:46:12

Judging History

你现在查看的是测评时间为 2024-10-09 16:46:12 的历史记录

  • [2024-11-05 22:04:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5270ms
  • 内存:394508kb
  • [2024-10-09 16:46:12]
  • 评测
  • 测评结果:100
  • 用时:5505ms
  • 内存:394388kb
  • [2024-10-09 16:46:11]
  • 提交

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;
	}
}

详细


Pretests


Final Tests

Test #1:

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

Test #2:

score: 40
Accepted
time: 1183ms
memory: 394320kb

Test #3:

score: 30
Accepted
time: 5505ms
memory: 394316kb