Submit Info #8872

Problem Lang User Status Time Memory
Montmort Number cpp gfonn AC 95 ms 10.05 MiB

ケース詳細
Name Status Time Memory
example_00 AC 0 ms 0.72 MiB
example_01 AC 2 ms 0.67 MiB
max_00 AC 95 ms 9.70 MiB
max_01 AC 85 ms 9.86 MiB
max_02 AC 84 ms 10.05 MiB
random_00 AC 38 ms 4.05 MiB
random_01 AC 44 ms 4.69 MiB
random_02 AC 53 ms 6.05 MiB
random_03 AC 41 ms 4.67 MiB
random_04 AC 70 ms 8.05 MiB

#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n, m; cin >> n >> m; ll prev = 0; for(int i=1; i<=n; i++) { cout << prev << " "; prev = (prev*(i+1))%m; if(i%2) prev = (prev+1)%m; else prev = (prev-1+m)%m; } return 0; }