cplib-cpp

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

View the Project on GitHub hitonanode/cplib-cpp

:warning: number/big_combination_logarithm.hpp

Code

#pragma once
#include <cmath>
#include <vector>

// CUT begin
constexpr double minusloginf = -300;
std::vector<double> logfac;
void facInit(int nmax) {
    logfac.assign(nmax + 1, 0);
    for (int i = 2; i <= nmax; i++) { logfac[i] = logfac[i - 1] + log(i); }
}
double lognCr(int n, int r) {
    if (n < r or r < 0) return minusloginf;
    return logfac[n] - logfac[r] - logfac[n - r];
}
#line 2 "number/big_combination_logarithm.hpp"
#include <cmath>
#include <vector>

// CUT begin
constexpr double minusloginf = -300;
std::vector<double> logfac;
void facInit(int nmax) {
    logfac.assign(nmax + 1, 0);
    for (int i = 2; i <= nmax; i++) { logfac[i] = logfac[i - 1] + log(i); }
}
double lognCr(int n, int r) {
    if (n < r or r < 0) return minusloginf;
    return logfac[n] - logfac[r] - logfac[n - r];
}
Back to top page