daylight-library

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub daylight-pro/daylight-library

:heavy_check_mark: 素数判定 (O(log(N))) (daylight/math/primality_test.hpp)

Depends on

Required by

Verified with

Code

#include "daylight/base.hpp"
#include "daylight/math/powmod.hpp"

/// @brief 素数判定 (O(log(N)))
bool is_prime(ll N) {
	if(N == 2) return true;
	if(N == 1 || N % 2 == 0) return false;
	ll s = 0;
	ll d = N - 1;
	while(d % 2 == 0) {
		s++;
		d /= 2;
	}
	vll tests
		= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };
	for(auto a: tests) {
		if(a == N) continue;
		ll X = pow_mod(a, d, N);
		int r = 0;
		if(X == 1) {
			continue;
		}
		while(X != N - 1) {
			X = pow_mod(X, 2, N);
			r++;
			if(X == 1 || r == s) return false;
		}
	}
	return true;
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.10/site-packages/competitive_verifier/oj_resolve/resolver.py", line 181, in resolve
    bundled_code = language.bundle(path, basedir=basedir)
  File "/home/runner/.local/lib/python3.10/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 252, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.10/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 482, in update
    self.update(
  File "/home/runner/.local/lib/python3.10/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 477, in update
    raise BundleErrorAt(
competitive_verifier.oj.verify.languages.cplusplus_bundle.BundleErrorAt: daylight/base.hpp: line 103: unable to process #include in #if / #ifdef / #ifndef other than include guards
Back to top page