QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624855#5. 在线 O(1) 逆元BlackPanda0 599ms394516kbC++14321b2024-10-09 16:45:102024-11-05 22:04:51

Judging History

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

  • [2024-11-05 22:04:51]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:599ms
  • 内存:394516kb
  • [2024-10-09 16:45:11]
  • 评测
  • 测评结果:0
  • 用时:627ms
  • 内存:394504kb
  • [2024-10-09 16:45:10]
  • 提交

answer

#include "inv.h"

const int N = 1e8+5;
const int P = 998244353;

int invv[N];

void init(int p)
{
	invv[1] = 1;
	for (int i = 2; i <= N; i ++ )
	{
		invv[i] = (p - p / i) * invv[p % i] % p;
	}
}

int inv(int x)
{
	if(x < N){
		return invv[x];
	} else {
		return (P - P / x) * inv(P % x) % P;
	}
}

詳細信息


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 554ms
memory: 394516kb

Test #2:

score: 0
Wrong Answer
time: 560ms
memory: 394400kb

Test #3:

score: 0
Wrong Answer
time: 599ms
memory: 394444kb

Test #4:

score: 0
Wrong Answer
time: 569ms
memory: 394444kb

Test #5:

score: 0
Wrong Answer
time: 571ms
memory: 394448kb