library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub yuruhi/library

:warning: math/BabystepGiantstep.cpp

Code

#pragma once
#include "./../template/functions.cpp"
#include <vector>
#include <unordered_map>
#include <cmath>

// g ^ result ≡ h (mod mod)
int64_t BabystepGiantstep(std::uint64_t g, std::uint64_t h, std::uint64_t mod) {
	const std::uint64_t m = std::ceil(std::sqrt(mod));
	std::unordered_map<std::uint64_t, std::uint64_t> table;
	std::uint64_t e = 1;
	for (std::uint64_t i = 0; i < m; ++i) {
		table[e] = i;
		e = e * g % mod;
	}
	e = h;
	for (std::uint64_t f = Powmod(g, mod - m - 1, mod), i = 0; i < m; ++i) {
		if (table.count(e)) {
			return i * m + table[e];
		}
		e = (e * f) % mod;
	}
	return -1;
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: ../template/functions.cpp: line -1: no such header
Back to top page