PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000034. Bước nhảy lớn nhất để ghé thăm mọi thành phố (Skip)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bước nhảy lớn nhất để ghé thăm mọi thành phố (Skip)
Skip
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are cities at distinct integer coordinates on a line. You start at , which differs from all city coordinates. Choose a positive step length ; every move changes your coordinate by exactly to the left or right. Find the greatest for which every city is reachable.
Input
The first line contains ; the second has the city coordinates.
Output
Print the maximum .
Subtasks
- Subtask 1 (20 points): ; ; All are pairwise distinct and differ from .
- Subtask 2 (30 points): ; ; All are pairwise distinct and differ from .
- Subtask 3 (50 points): ; ; All are pairwise distinct and differ from .
Examples
Input
3 3
1 7 11
Output
2
Explanation
With , all three locations are reachable from . The step length must divide distances , whose GCD is .