Submit Info #3206

Problem Lang User Status Time Memory
Montmort Number cpp satashun AC 101 ms 13.92 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.67 MiB
example_01 AC 2 ms 0.68 MiB
max_00 AC 101 ms 13.47 MiB
max_01 AC 92 ms 13.67 MiB
max_02 AC 85 ms 13.92 MiB
random_00 AC 36 ms 5.55 MiB
random_01 AC 42 ms 6.42 MiB
random_02 AC 55 ms 8.17 MiB
random_03 AC 40 ms 6.27 MiB
random_04 AC 75 ms 11.14 MiB

#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() #ifdef LOCAL #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define dump(x) true #endif constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; } template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; } template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os<<"("<<p.first<<","<<p.second<<")"; return os; } template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"{"; rep(i, v.size()) { if (i) os<<","; os<<v[i]; } os<<"}"; return os; } const int maxn = 1000010; int dp[maxn]; int main() { int N, M; cin >> N >> M; dp[1] = 0; dp[2] = 1 % M; for (int i = 3; i <= N; ++i) { dp[i] = (ll)(dp[i-1] + dp[i-2]) * (i-1) % M; } for (int i = 1; i <= N; ++i) { printf("%d%c", dp[i], i == N ? '\n' : ' '); } return 0; }