cswork / OA打开练习工作台

UberOA #15

Prime Jumps — Maximum Game Score

估计中等可在线判题

考点(AI 标注)动规入门位运算

Start at cell 0 with a score of 0. Each move jumps 1 cell to the right, or jumps a prime number of cells whose last decimal digit is 3. The value of the landing cell is added to the score, and you must finish at n−1. Find the highest score.

This site's standard input/output is stated explicitly.

输入格式

The first line contains n, and the second line contains n cell values. 1≤n≤10000, −10000≤cell[i]≤10000, cell[0]=0.

输出格式

Output one integer answer.

样例 1

输入:

5
0 -10 -20 -30 50

输出:

40

样例 2

输入:

1
0

输出:

0

样例 3

输入:

4
0 1 1 1

输出:

3

样例说明

Example 1: 0→1→4 scores −10+50=40, which beats the 20 obtained by jumping 3 first. Example 2: the start is the end, so the score is 0. Example 3: moving cell by cell gives 3, and skipping positive cells is never better.