QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624870#5. 在线 O(1) 逆元dww_1337100 ✓5553ms394512kbC++14324b2024-10-09 16:47:102024-11-05 22:04:59

Judging History

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

  • [2024-11-05 22:04:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5553ms
  • 内存:394512kb
  • [2024-10-09 16:47:10]
  • 评测
  • 测评结果:70
  • 用时:1538ms
  • 内存:394456kb
  • [2024-10-09 16:47:10]
  • 提交

answer

#include "inv.h"

const int MAXN = 1e8 + 5;
const int MOD = 998244353;
int invt[MAXN];

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

int inv(int x)
{
	if(x < MAXN) return invt[x];
	else return  MOD - 1ll * (MOD / x) * inv(MOD % x) % MOD;
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 880ms
memory: 394464kb

Test #2:

score: 20
Accepted
time: 1354ms
memory: 394484kb

Test #3:

score: 30
Accepted
time: 3224ms
memory: 394408kb

Test #4:

score: 20
Accepted
time: 4602ms
memory: 394452kb

Test #5:

score: 20
Accepted
time: 5553ms
memory: 394512kb