Submit Info #13623

Problem Lang User Status Time Memory
Montmort Number cpp kya AC 93 ms 13.91 MiB

ケース詳細
Name Status Time Memory
example_00 AC 2 ms 0.71 MiB
example_01 AC 1 ms 0.72 MiB
max_00 AC 93 ms 13.51 MiB
max_01 AC 87 ms 13.61 MiB
max_02 AC 85 ms 13.91 MiB
random_00 AC 38 ms 5.56 MiB
random_01 AC 43 ms 6.42 MiB
random_02 AC 52 ms 8.17 MiB
random_03 AC 38 ms 6.29 MiB
random_04 AC 72 ms 11.21 MiB

#include <vector> struct montmort { private : std::vector<int> table; public : montmort (std::size_t n, int mod) : table(n + 4, 0) { table[2] = 1; table[3] = 2; for (int i = 4; i <= n; i++) { table[i] = (1LL * (i - 1) * (table[i - 1] + table[i - 2])) % mod; } } const int& operator[] (int i) const { return (table[i]); } }; #include <iostream> int main() { int n, m; std::cin >> n >> m; montmort num(n, m); for (int i = 1; i <= n; i++) { std::cout << num[i] << ' '; } return 0; }