You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
406 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int a[N];
int main()
{
int n, x;
scanf("%d%d", &n, &x);
for (int i = 0; i < n; i++)
scanf("%d", a + i), a[i] = abs(a[i] - x);
int g = *a;
for (int i = 0; i < n; i++)
g = gcd(g, a[i]);
printf("%d", g);
return 0;
}