Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <string.h>
- //#include <limits>
- //#include <algorithm>
- //#include <math.h>
- //#include <bitset> // bitset< 32 >( num ).to_string();
- #define ll long long
- #define print(var) cout << #var << ": " << var << endl;
- #define println(var); cout << var << endl;
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- int a;
- while (cin >> a && a != 0) {
- int* m = new int[a];
- //print(a);
- bool sameNum = true;
- for (int i = 0; i < a; i++) {
- cin >> m[i];
- if (i > 0) {
- if (m[i] != m[i - 1]) {
- sameNum = false;
- }
- }
- }
- //print(sameNum);
- if (sameNum) {
- cout << sameNum << endl;
- }
- else {
- int n = 2;
- //print(n);
- sameNum = true;
- int lastPass = 0;
- while (n <= a / 2) {
- int lastN;
- //print(n);
- for (int j = 0; j < n; j++) {
- for (int i = j; i < a; i += n) {
- if (i > j) {
- if (lastN != m[i]) {
- //print(m[i]);
- i = a;
- j = a;
- }
- }
- lastN = m[i];
- }
- if (j == n - 1) {
- if (lastPass == 0) {
- lastPass = j + 1;
- n = a;
- }
- }
- }
- n++;
- }
- cout << lastPass << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment