P27822 [洛谷] [Information and Future 2018] Greatest Common Divisor
普及-
题目描述

Problem Description

Given three positive integers \( x, y, z \), find their greatest common divisor (GCD) \( g \): the largest positive integer \( g \geq 1 \) such that \( x, y, z \) are all multiples of \( g \), i.e., \( (x \bmod g) = (y \bmod g) = (z \bmod g) = 0 \).

Input Format

A single line containing three positive integers \( x, y, z \).

Output Format

A single line containing one integer \( g \), representing the greatest common divisor of \( x, y, z \).

Sample Input and Output

Sample Input #1

12 34 56

Sample Output #1

2

Sample Input #2

28 70 28

Sample Output #2

14

Notes

Sample Explanation

Sample 1

\( 12 = 2 \times 6, 34 = 2 \times 17, 56 = 2 \times 28, g = 2 \).

Sample 2

\( 28 = 14 \times 2, 70 = 14 \times 5, 28 = 14 \times 2, g = 14 \).

Data Constraints

All data satisfy \( 1 \leq x, y, z \leq 10^6 \).

This problem originally had a full score of 15 points.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
12 34 56
样例输出
2