Submit Info #4938

Problem Lang User Status Time Memory
Montmort Number cpp chocorusk AC 95 ms 17.67 MiB

ケース詳細
Name Status Time Memory
example_00 AC 3 ms 0.72 MiB
example_01 AC 1 ms 0.67 MiB
max_00 AC 95 ms 17.30 MiB
max_01 AC 90 ms 17.39 MiB
max_02 AC 87 ms 17.67 MiB
random_00 AC 38 ms 7.05 MiB
random_01 AC 43 ms 8.17 MiB
random_02 AC 52 ms 10.41 MiB
random_03 AC 41 ms 7.99 MiB
random_04 AC 71 ms 14.30 MiB

#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<ll, ll> P; int main() { int n; ll m; scanf("%d %lld", &n, &m); ll dp[1000010]; dp[1]=0, dp[2]=1%m; for(int i=3; i<=n; i++){ dp[i]=(dp[i-1]+dp[i-2])*(i-1)%m; } for(int i=1; i<=n; i++) printf("%lld ", dp[i]); printf("\n"); return 0; }