templates

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

View the Project on GitHub plasmatic1/templates

:heavy_check_mark: math/choose.hpp

Depends on

Required by

Verified with

Code

#include "../template.hpp"
#pragma once

// N choose R
template <typename T> struct Choose {
    vector<T> fact, invf;
    void init(int N) {
        fact.resize(N + 1); invf.resize(N + 1);
        fact[0] = 1;
        for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i;
        invf[N] = 1 / fact[N];
        for (auto i = N - 1; i >= 0; i--) invf[i] = invf[i + 1] * (i + 1);
    }
    T choose(T N, T K) { return fact[N] * invf[K] * invf[N - K]; }
    T permute(T N, T K) { return fact[N] * invf[N - K]; }
};
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/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.10.6/x64/lib/python3.10/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/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: math/choose.hpp: line 2: #pragma once found in a non-first line
Back to top page