Submit Info #8869

Problem Lang User Status Time Memory
Montmort Number cpp (anonymous) AC 93 ms 17.73 MiB

ケース詳細
Name Status Time Memory
example_00 AC 2 ms 0.68 MiB
example_01 AC 2 ms 0.67 MiB
max_00 AC 93 ms 17.31 MiB
max_01 AC 89 ms 17.42 MiB
max_02 AC 88 ms 17.73 MiB
random_00 AC 36 ms 7.07 MiB
random_01 AC 46 ms 8.24 MiB
random_02 AC 55 ms 10.42 MiB
random_03 AC 38 ms 7.92 MiB
random_04 AC 72 ms 14.30 MiB

#include <bits/stdc++.h> using namespace std; #define forsn(i, s, n) for(int i=s;i<int(n);i++) #define forn(i, n) forsn(i, 0, n) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long tint; typedef long double ld; const int INF = 190000000; const int MOD = 1e9+7; int main(){ int n, m; cin >> n >> m; tint dp[n+1]; dp[0] = 1; dp[1] = 0; dp[2] = 1; forsn(i, 3, n+1){ dp[i] = (i-1)*(dp[i-1]+dp[i-2]) % m; } forsn(i, 1, n+1){ cout << dp[i] << " "; } }