library

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

View the Project on GitHub kk2a/library

:heavy_check_mark: math/multiplicative_function/sigma.hpp

Depends on

Verified with

Code

#ifndef KK2_MATH_MULTIPLICATIVE_FUNCTION_SIGMA_HPP
#define KK2_MATH_MULTIPLICATIVE_FUNCTION_SIGMA_HPP 1

#include <cassert>

#include "../../type_traits/integral.hpp"
#include "../pow.hpp"
#include "../prime_factorize.hpp"

namespace kk2 {

template <class T, is_integral_t<T> * = nullptr> T sigma0(T n) {
    assert(n > 0);
    T res = 1;
    for (auto [p, k] : factorize(static_cast<long long>(n))) res *= k + 1;
    return res;
}

template <class T, is_integral_t<T> * = nullptr> T sigma1(T n) {
    assert(n > 0);
    T res = 1;
    for (auto [p, k] : factorize(static_cast<long long>(n))) {
        T p_k = pow<T>(p, k);
        res *= p_k + (p_k - 1) / (p - 1);
    }
    return res;
}

} // namespace kk2

#endif // KK2_MATH_MULTIPLICATIVE_FUNCTION_SIGMA_HPP
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/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 "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.12.0/x64/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 "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 312, in update
    raise BundleErrorAt(path, i + 1, "#pragma once found in a non-first line")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: type_traits/integral.hpp: line 4: #pragma once found in a non-first line
Back to top page