QOJ.ac

QOJ

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

Judging History

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

  • [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: 10
Accepted
time: 697ms
memory: 394328kb

Test #2:

score: 20
Accepted
time: 1143ms
memory: 394468kb

Test #3:

score: 30
Accepted
time: 2952ms
memory: 394452kb

Test #4:

score: 20
Accepted
time: 4368ms
memory: 394408kb

Test #5:

score: 20
Accepted
time: 5270ms
memory: 394508kb