QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#128665#5. 在线 O(1) 逆元Leasier70 821ms81744kbC++11358b2023-07-21 14:40:202023-07-21 14:40:40

Judging History

你现在查看的是测评时间为 2023-07-21 14:40:40 的历史记录

  • [2024-11-05 21:50:58]
  • 管理员手动重测本题所有提交记录
  • 测评结果:60
  • 用时:4086ms
  • 内存:81960kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-21 14:40:40]
  • 评测
  • 测评结果:70
  • 用时:821ms
  • 内存:81744kb
  • [2023-07-21 14:40:20]
  • 提交

answer

#include "inv.h"

const int N = 2e7;
int mod;
int inv_list[N + 7];

void init(int p){
	mod = p;
	inv_list[0] = inv_list[1] = 1;
	for (register int i = 2; i <= N; i++){
		inv_list[i] = mod - 1ll * (mod / i) * inv_list[mod % i] % mod;
	}
}

int inv(int x){
	if (x <= N) return inv_list[x];
	return mod - 1ll * (mod / x) * inv(mod % x) % mod;
}

詳細信息

Test #1:

score: 30
Accepted
time: 160ms
memory: 81704kb

Test #2:

score: 40
Accepted
time: 821ms
memory: 81744kb

Test #3:

score: 0
Time Limit Exceeded