serna37's Library

Logo

C++ アルゴリズムとデータ構造のライブラリ

View the Project on GitHub serna37/library-cpp

:heavy_check_mark: エラトステネスの篩のテスト
(tests/number.prime.eratosthenes.test.cpp)

Depends on

Code

#define PROBLEM                                                                \
    "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A"
#include "template/template.hpp"
#include "library/number/prime/eratosthenes.hpp"
#include "library/number/prime/prime_test.hpp"
#include "library/number/prime/prime_fact.hpp"
#include "library/number/prime/euler_phi.hpp"
#include "library/number/divisors.hpp"
/**
 * @brief エラトステネスの篩のテスト
 */
void test() {
    int N = 1000000;
    Eratosthenes er(N);
    int x = 999982;
    // 素数判定
    bool is_p = er.is_prime(x);
    assert(is_p == prime_test(x));
    // 素因数分解 <素因数: 個数>
    vector<pair<int, int>> factors = er.factorize(x);
    map<int, int> mp = prime_fact(x);
    for (auto &&[p, cnt] : factors) {
        assert(mp[p] == cnt);
    }
    // 約数列挙 (ソートされてないよ)
    vector<int> divs = er.calc_divisors(x);
    vector<int> exp = divisors(x);
    sort(all(divs));
    sort(all(exp));
    assert(divs == exp);
    // 最小素因数
    int lpf = er.lpf(x);
    assert(lpf == 2ll);
    // φ(x)
    int phi = er.euler_phi(x);
    assert(phi == euler_phi(x));
}
void solve() {
    print("Hello World");
    test();
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/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 "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
  File "/home/runner/.local/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 400, in update
    raise BundleErrorAt(path, i + 1, "unable to process #include in #if / #ifdef / #ifndef other than include guards")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: template/template.hpp: line 7: unable to process #include in #if / #ifdef / #ifndef other than include guards
Back to top page