Logo
(追記) (追記ここまで)

32060번 - Doubled GCD 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB69444365.152%

문제

There are $N$ cards in a deck, numbered from 1ドル$ to $N,ドル where card $i$ has a positive integer $A_i$ written on it.

You are to perform $N - 1$ moves with the cards. In each move, you select two cards of your choice from the deck. Let $x$ and $y$ be the integers written on the selected cards, respectively. Remove both selected cards, and insert a new card into the deck with 2ドル \cdot \gcd(x, y)$ written on it, where $\gcd(x, y)$ is the greatest common divisor of $x$ and $y$. Note that with this one move, there will be one fewer card in the deck (as you remove two cards and insert one new card).

After all $N -1$ moves have been performed, there will be exactly one card remaining. Your goal is to maximize the integer written on the last card; output this integer.

입력

Input begins with an integer $N$ (2ドル ≤ N ≤ 100,円 000$) representing the number of cards. The next line contains $N$ integers $A_i$ (1ドル ≤ A_i ≤ 10^9$) representing the number written on card $i$.

출력

Output an integer in a single line representing the maximum possible integer written on the last card.

제한

예제 입력 1

3
2 4 6

예제 출력 1

8

To get the maximum possible integer on the last card, you have to select card 1ドル$ and card 3ドル$ on the first move with $x = 2$ and $y = 6$. Remove both selected cards, and insert a new card with 2ドル \cdot \gcd(2, 6) = 4$ written on it. For the second move, there are two cards remaining with an integer 4ドル$ written on each card. Select those cards with $x = 4$ and $y = 4$. Remove both selected cards, and insert a new card with 2ドル \cdot \gcd(4, 4) = 8$ written on it. The last card has an integer 8ドル$ written on it, and it is the maximum possible integer in this example.

예제 입력 2

3
3 5 7

예제 출력 2

2

Regardless of your choice in each move, the answer will always be 2ドル$.

예제 입력 3

4
9 9 9 9

예제 출력 3

36

예제 입력 4

5
10 100 1000 10000 100000

예제 출력 4

160

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Jakarta > The 2022 ICPC Asia Jakarta Regional Contest F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /