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

31557번 - Cowlendar 다국어

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

문제

Bessie has woken up on a strange planet. In this planet, there are $N$ (1ドル\le N\le 10^4$) months, with $a_1, \ldots, a_N$ days, respectively (1ドル\leq a_i \leq 4 \cdot 10^9,ドル all $a_i$ are integers). In addition, on the planet, there are also weeks, where each week is $L$ days, with $L$ being a positive integer. Interestingly, Bessie knows the following:

  • For the correct $L,ドル each month is at least 4ドル$ weeks long.
  • For the correct $L,ドル there are at most 3ドル$ distinct values of $a_i\bmod L$.

Unfortunately, Bessie has forgotten what $L$ is! Help her by printing the sum of all possible values of $L$.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

입력

The first line contains a single integer $N$. The second line contains $N$ space-separated integers, $a_1, \ldots, a_N$.

출력

A single integer, the sum of all possible values of $L$.

제한

예제 입력 1

12
31 28 31 30 31 30 31 31 30 31 30 31

예제 출력 1

28

The possible values of $L$ are 1, 2, 3, 4, 5, 6, and 7. For example, $L=7$ is valid because each month is at least length 4ドル \cdot 7 = 28$ days long, and each month is either 0, 2, or 3 mod 7.

예제 입력 2

4
31 35 28 29

예제 출력 2

23

The possible values of $L$ are 1, 2, 3, 4, 6, and 7. For example, $L=6$ is valid because each month is at least length 4ドル \cdot 6 = 24$ days long, and each month is either 1, 4, or 5 mod 6.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 January Contest > Silver 3번

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

출처

대학교 대회

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

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