# Submit Info #11882

Problem Lang User Status Time Memory
Montmort Number cpp Bogdan AC 85 ms 13.92 MiB

ケース詳細
Name Status Time Memory
example_00 AC 3 ms 0.67 MiB
example_01 AC 1 ms 0.67 MiB
max_00 AC 84 ms 13.55 MiB
max_01 AC 85 ms 13.70 MiB
max_02 AC 79 ms 13.92 MiB
random_00 AC 32 ms 5.55 MiB
random_01 AC 40 ms 6.48 MiB
random_02 AC 49 ms 8.30 MiB
random_03 AC 35 ms 6.30 MiB
random_04 AC 66 ms 11.17 MiB

#ifdef DEBUG #define _GLIBCXX_DEBUG #endif //#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; int mod; int mult(int a, int b) { return (1LL * a * b) % mod; } int pw(int a, int b) { if (b == 0) return 1; if (b & 1) return mult(a, pw(a, b - 1)); int res = pw(a, b / 2); return mult(res, res); } int sub(int a, int b) { int s = a - b; if (s < 0) s += mod; return s; } int sum(int a, int b) { int s = a + b; if (s >= mod) s -= mod; return s; } int n, m; vector < int > dearr(int n, int mod) { ::mod = mod; vector < int > ans(n + 1); ans[0] = 1; for (int i = 1; i <= n; i++) { ans[i] = mult(i, ans[i - 1]); if (i & 1) { ans[i] = sub(ans[i], 1); } else { ans[i] = sum(ans[i], 1); } } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // freopen("input.txt", "r", stdin); cin >> n >> m; auto dt = dearr(n, m); for (int i = 1; i <= n; i++) cout << dt[i] << " "; return 0; }