QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624807#5. 在线 O(1) 逆元dww_133770 1568ms394456kbC++14324b2024-10-09 16:39:242024-10-09 16:39:24

Judging History

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

  • [2024-11-05 22:04:46]
  • 管理员手动重测本题所有提交记录
  • 测评结果:80
  • 用时:5002ms
  • 内存:394328kb
  • [2024-10-09 16:39:24]
  • 评测
  • 测评结果:70
  • 用时:1568ms
  • 内存:394456kb
  • [2024-10-09 16:39:24]
  • 提交

answer

#include "inv.h"

const int MAXN = 1e8 + 7;
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: 30
Accepted
time: 1036ms
memory: 394400kb

Test #2:

score: 40
Accepted
time: 1568ms
memory: 394456kb

Test #3:

score: 0
Time Limit Exceeded