#P10403. 「XSOI-R1」跳跃游戏
「XSOI-R1」跳跃游戏
Background
The poor originally came up with this problem, but it was already taken by . At this moment, sat in front of the computer, looking at the testdata that was almost ready, imagining his dream of having his problem stump a large number of contestants shattering.
Problem Description
This is a jumping game. In the game, you can jump to any position. There are points: . Jumping there gives you reward scores .
Obviously, this game is very easy. got all the scores in no time, so he improved the code by adding a parameter called experience points.
For the points with reward scores, if you jump from point to point , you will gain experience points :
$$\operatorname{score}_{x,y}=\begin{cases}\operatorname{len} & \operatorname{gcd}(a_x , a_{x+1} , \dots , a_y)=2 , \operatorname{len \ mod} 2 = 0 \\ \operatorname{len} &\gcd(a_x , a_{x + 1} , \dots , a_y)=3 , \operatorname{len \ mod} 2 = 1\\ 0 & \operatorname{others} \end{cases}$$Here, denotes the length of the interval, i.e., .
For each pair of positions , jumping multiple times will only grant experience points once.
To show your programming skills, you decide to write a program to compute the maximum total experience points that can be obtained in this game.
Input Format
The input has two lines.
The first line contains an integer .
The second line contains integers .
Output Format
Output one integer, representing the answer.
5
2 3 6 3 9
8
5
2 2 2 2 2
16
9
6 2 3 6 4 6 8 2 5
19
Hint
Please use a fast input method.
Sample Explanation #1
.
.
.
.
.
Sample Explanation #2
.
.
.
.
.
.
.
Constraints
This problem uses bundled tests.
-
Subtask 0 (20 pts): .
-
Subtask 1 (10 pts): .
-
Subtask 2 (20 pts): .
-
Subtask 3 (50 pts): .
For all testdata, , .
Translated by ChatGPT 5