#P10136. [USACO24JAN] Cowlendar S
[USACO24JAN] Cowlendar S
Description
Bessie has woken up on a strange planet. In this planet, there are () months, with days, respectively (, all are integers). In addition, on the planet, there are also weeks, where each week is days, with being a positive integer. Interestingly, Bessie knows the following:
- For the correct , each month is at least weeks long.
- For the correct , there are at most distinct values of .
Unfortunately, Bessie has forgotten what is! Help her by printing the sum of all possible values of .
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++).
Input Format
The first line contains a single integer . The second line contains space-separated integers, .
Output Format
A single integer, the sum of all possible values of .
12
31 28 31 30 31 30 31 31 30 31 30 31
28
4
31 35 28 29
23
Hint
For Sample 1:
The possible values of are 1, 2, 3, 4, 5, 6, and 7. For example, is valid because each month is at least length days long, and each month is either 0, 2, or 3 mod 7.
For Sample 2:
The possible values of are 1, 2, 3, 4, 6, and 7. For example, is valid because each month is at least length days long, and each month is either 1, 4, or 5 mod 6.
SCORING:
- Inputs 3-4:
- Inputs 5-14: No additional constraints
京公网安备 11011102002149号