library

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

View the Project on GitHub matumoto1234/library

:warning: math/binomial-table.hpp

Depends on

Code

#pragma once

#include "./base.hpp"

#include <vector>

namespace matumoto {
  template <typename T>
  struct BinomialTable {
    vector<vector<T>> data;
    BinomialTable(int N) {
      data.assign(N + 1, vector<T>(N + 1, 0));
      data[0][0] = 1;
      for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
          data[i + 1][j] += data[i][j];
          data[i + 1][j + 1] += data[i][j];
        }
      }
    }

    T query(int n, int r) {
      return data[n][r];
    }
  };
} // namespace matumoto
#line 2 "math/binomial-table.hpp"

#line 2 "math/base.hpp"

namespace matumoto {
  using namespace std;
  using ll = long long;
} // namespace matumoto
#line 4 "math/binomial-table.hpp"

#include <vector>

namespace matumoto {
  template <typename T>
  struct BinomialTable {
    vector<vector<T>> data;
    BinomialTable(int N) {
      data.assign(N + 1, vector<T>(N + 1, 0));
      data[0][0] = 1;
      for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
          data[i + 1][j] += data[i][j];
          data[i + 1][j + 1] += data[i][j];
        }
      }
    }

    T query(int n, int r) {
      return data[n][r];
    }
  };
} // namespace matumoto
Back to top page