AtCoder Regular Contest 105
翻译中…
Problem Statement
翻译中…
Snuke had $N$ cards numbered $1$ through $N$. Each card has an integer written on it; written on Card $i$ is $a_i$.
翻译中…
Snuke did the following procedure:
翻译中…
- Let
$X$and$x$be the maximum and minimum values written on Snuke's cards, respectively. - If
$X = x$, terminate the procedure. Otherwise, replace each card on which$X$is written with a card on which$X-x$is written, then go back to step 1.
翻译中…
Under the constraints in this problem, it can be proved that the procedure will eventually terminate. Find the number written on all of Snuke's cards after the procedure.
翻译中…
Constraints
翻译中…
- All values in input are integers.
$1 \leq N \leq 10^{5}$$1 \leq a_i \leq 10^9$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
a_1 a_2 \cdots a_N
翻译中…
Output
翻译中…
Print the number written on all of Snuke's cards after the procedure.
翻译中…
样例
Input #1
3
2 6 6
Output #1
2
- At the beginning of the procedure, the numbers written on Snuke's cards are $(2,6,6)$.
- Since $x=2$ and $X=6$, he replaces each card on which $6$ is written with a card on which $4$ is written.
- Now, the numbers written on Snuke's cards are $(2,4,4)$.
- Since $x=2$ and $X=4$, he replaces each card on which $4$ is written with a card on which $2$ is written.
- Now, the numbers written on Snuke's cards are $(2,2,2)$.
- Since $x=2$ and $X=2$, he terminates the procedure.
Input #2
15
546 3192 1932 630 2100 4116 3906 3234 1302 1806 3528 3780 252 1008 588
Output #2
42
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。