#include <iostream>
#include <vector>
using namespace std;
int gcd(int x, int y) {
if (y == 0) return x;
else return gcd(y, x%y);
}
int main() {
int n, s;
cin >> n >> s;
vector<int> a(n);
for (int i=0; i<n; i++) {
int x;
cin >> x;
int diff = x-s;
if (diff < 0) diff = -diff;
a[i] = diff;
}
int ans = a[0];
for (int i=1; i<n; i++) {
ans = gcd(ans, a[i]);
}
cout << ans << '\n';
return 0;
}
'Problem set' 카테고리의 다른 글
[백준] 2309 일곱 난쟁이 (0) | 2021.01.19 |
---|---|
[백준] 17413: 단어 뒤집기 2 (0) | 2020.12.29 |
[백준] 16194: 카드 구매하기 2 (0) | 2020.12.29 |
[백준] 11727: 2×n 타일링 2 (0) | 2020.12.29 |
[백준] 11726: 2×n 타일링 (0) | 2020.12.29 |