pastebin

Paste Search Dynamic
Recent pastes
gcd
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5.  
  6. int main()
  7. {
  8.     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  9.  
  10.     int n;
  11.     cin >> n;
  12.  
  13.     int x = 0, a[n + 9];
  14.     for (int i = 1; i <= n; i++) {
  15.         cin >> a[i];
  16.         if (i > 1) x = __gcd(x, abs(a[i] - a[i - 1]));
  17.     }
  18.  
  19.     cout << (x == 1 ? 2 : 1);
  20. }
Parsed in 0.005 seconds