当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5730:Shell Necklace

题目描述
Perhaps the sea‘s definition of a shell is the pearl. However, in my view, a shell necklace with n beautiful shells contains the most sincere feeling for my best lover Arrietty, but even that is not enough.

Suppose the shell necklace is a sequence of shells (not a chain end to end). Considering i continuous shells in the shell necklace, I know that there exist different schemes to decorate the i shells together with one declaration of love.

I want to decorate all the shells with some declarations of love and decorate each shell just one time. As a problem, I want to know the total number of schemes.
输入解释
There are multiple test cases(no more than $20$ cases and no more than 1 in extreme case), ended by 0.

For each test cases, the first line contains an integer $n$, meaning the number of shells in this shell necklace, where $1 \leq n \leq 10^{5}$. Following line is a sequence with $n$ non-negative integer $a_{1},a_{2},…,a_{n}$, and $a_{i} \leq 10^{7}$ meaning the number of schemes to decorate $i$ continuous shells together with a declaration of love.
输出解释
For each test case, print one line containing the total number of schemes module $313$(Three hundred and thirteen implies the march 13th, a special and purposeful day).
输入样例
3
1 3 7
4
2 2 2 2 
0
输出样例
14
54
提示


For the first test case in Sample Input, the Figure 1 provides all schemes about it. The total number of schemes is 1 + 3 + 3 + 7 = 14.
来自杭电HDUOJ的附加信息
Author HIT
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5730

最后修改于 2020-10-25T23:25:10+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/8000MS(Java/Others) 65536/65536K(Java/Others)