QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293463#5. 在线 O(1) 逆元iee100 ✓4963ms394452kbC++14389b2023-12-29 10:34:312024-11-05 21:57:10

Judging History

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

  • [2024-11-05 21:57:10]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:4963ms
  • 内存:394452kb
  • [2023-12-29 10:34:33]
  • 评测
  • 测评结果:70
  • 用时:1232ms
  • 内存:394248kb
  • [2023-12-29 10:34:31]
  • 提交

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) {
	if (x < N) return v[x];
	return P - 1ll * inv(P % x) * (P / x) % P;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 616ms
memory: 394452kb

Test #2:

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

Test #3:

score: 30
Accepted
time: 2780ms
memory: 394396kb

Test #4:

score: 20
Accepted
time: 4073ms
memory: 394296kb

Test #5:

score: 20
Accepted
time: 4963ms
memory: 394376kb