QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293466#5. 在线 O(1) 逆元iee0 683ms394456kbC++11435b2023-12-29 10:41:322023-12-29 10:41:33

Judging History

你现在查看的是测评时间为 2023-12-29 10:41:33 的历史记录

  • [2024-11-05 21:57:23]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:712ms
  • 内存:394512kb
  • [2023-12-29 10:41:33]
  • 评测
  • 测评结果:0
  • 用时:683ms
  • 内存:394456kb
  • [2023-12-29 10:41:32]
  • 提交

answer

#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "inv.h"
using namespace std;
constexpr int N = 1e8;
int v[N], P;
void init(int p) {
	P = p;
	v[1] = 1;
	for (int i = 2; i < N; i++) {
		v[i] = P - 1ll * v[P % i] * (P / i) % P;
	}
}
int inv(int x) {
	int res = 1;
	while (x >= N) {
		res = P - 1ll * res * (P / x);
		x = P % x;
	}
	return 1ll * res * v[x] % P;
}

详细

Test #1:

score: 0
Wrong Answer
time: 678ms
memory: 394412kb

Test #2:

score: 0
Wrong Answer
time: 683ms
memory: 394112kb

Test #3:

score: 0
Wrong Answer
time: 677ms
memory: 394456kb