PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000052. Tìm mô-đun chung từ các phần dư bằng nhau (Simple division)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm mô-đun chung từ các phần dư bằng nhau (Simple division)
Simple division
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers (possibly negative), find the greatest positive integer for which every has the same Euclidean remainder modulo . If all values are equal, output 0 by convention.
Input
The first line contains ; the next contains exactly integers.
Output
Print the largest positive modulus, or 0 by convention.
Subtasks
- Subtask 1 (20 points): ; (Phuoc Hung OJ version bound)
- Subtask 2 (30 points): ; (Phuoc Hung OJ version bound)
- Subtask 3 (50 points): ; (Phuoc Hung OJ version bound)
Examples
Input
4
7 13 19 25
Output
6
Explanation
All four numbers have remainder modulo . Their differences from are , whose GCD is .