kyopro-lib

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

View on GitHub

:x: Montmort number
(Mylib/Combinatorics/montmort_number.cpp)

Operations

Requirements

Notes

Problems

References

Verified with

Code

#pragma once
#include <vector>

namespace haar_lib {
  template <typename T>
  std::vector<T> montmort_number(int n) {
    std::vector<T> ret(n + 1);

    ret[0] = 1;
    ret[1] = 0;
    ret[2] = 1;

    for (int i = 3; i <= n; ++i) {
      ret[i] = (ret[i - 1] + ret[i - 2]) * (i - 1);
    }

    return ret;
  }
}  // namespace haar_lib
#line 2 "Mylib/Combinatorics/montmort_number.cpp"
#include <vector>

namespace haar_lib {
  template <typename T>
  std::vector<T> montmort_number(int n) {
    std::vector<T> ret(n + 1);

    ret[0] = 1;
    ret[1] = 0;
    ret[2] = 1;

    for (int i = 3; i <= n; ++i) {
      ret[i] = (ret[i - 1] + ret[i - 2]) * (i - 1);
    }

    return ret;
  }
}  // namespace haar_lib
Back to top page