#P7810. [JRKSJ R2] Upper
[JRKSJ R2] Upper
Problem Description
There are poker cards. On the -th card, there is a positive integer .
Now you need to divide the cards into several legal consecutive segments. A consecutive segment is “legal” if and only if it satisfies both conditions:
- .
- .
Ask for the maximum number of segments you can divide into. If there is no legal partition plan, output .
If you do not know what means, see the “Hint” section.
Input Format
The first line contains an integer .
The second line contains integers representing the sequence .
Output Format
Output one integer, as described in the statement.
5
2 1 8 3 9
2
5
5 4 3 2 1
-1
20
20 9 36 36 40 8 3 10 9 20 18 12 30 20 30 15 8 9 27 45
7
Hint
Constraints
This problem uses bundled testdata.
For of the testdata, , .
| Special property | Score | |||
|---|---|---|---|---|
| None | ||||
| Random testdata | ||||
| None |
Sample Explanation
For Sample , there is one and only one partition plan: .
For Sample , there is no legal partition plan.
Hint
For two positive integers , is their greatest common divisor, i.e. the largest number that is a divisor of both and .
Translated by ChatGPT 5