Submit Info #8871

Problem Lang User Status Time Memory
Montmort Number cpp (anonymous) AC 91 ms 10.05 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.70 MiB
example_01 AC 1 ms 0.67 MiB
max_00 AC 91 ms 9.67 MiB
max_01 AC 88 ms 9.80 MiB
max_02 AC 85 ms 10.05 MiB
random_00 AC 36 ms 4.05 MiB
random_01 AC 43 ms 4.67 MiB
random_02 AC 52 ms 5.98 MiB
random_03 AC 41 ms 4.67 MiB
random_04 AC 67 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; }