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

15206번 - GCD-sum 다국어

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

문제

A multi-set (i.e. a set with possible repetitions) of $n$ integers is given. We split the set into $k$ disjoint groups, for every group we compute the greatest common divisor of its elements, and sum all the subsets' GCDs.

For every $k = 1, 2, \ldots, n,ドル determine the maximal sum which can be obtained this way

입력

In the first line of input there is a single integer $n$ (1ドル \leq n \leq 500,000円$) -- the cardinality of the set. In the second line, there are $n$ positive integers, not exceeding 10ドル^{12}$ -- the given sequence.

출력

Output $n$ line scontaining one integer each -- the best sum of GCDs when partitioning into 1ドル,ドル 2ドル,ドル $\ldots,ドル $n$ subsets.

제한

예제 입력 1

4
10 9 10 3

예제 출력 1

1
13
23
32

예제 입력 2

8
15 25 29 30 43 44 45 55

예제 출력 2

1
56
101
145
188
221
256
286

힌트

For $k = 2,ドル the best partition is $(10,10)$ and $(9,3),ドル giving the sum of 10ドル+3 = 13$. For $k=3,ドル the best partition is $(10),ドル $(10)$ and $(9,3)$ with the sum of 23ドル$.

출처

Camp > Czech, Polish and Slovak Preparation Camp > CPSPC 2017 2-1번

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

출처

대학교 대회

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

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