Problem 2588 --Chiaki Sequence Revisited

2588: Chiaki Sequence Revisited

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $4$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

Chiaki is interested in an infinite sequence a1,a2,a3,..., which is defined as follows: 

an={1  n=1,2

an−an−1+an−1−an−2  n>2

}


Chiaki would like to know the sum of the first n terms of the sequence, i.e. ∑i=1nai. As this number may be very large, Chiaki is only interested in its remainder modulo (109+7).


There are multiple test cases. The first line of input contains an integer T (1≤T≤105), indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤1018).
For each test case, output an integer denoting the answer.
10
1
2
3
4
5
6
7
8
9
10
1
2
4
6
9
13
17
21
26
32

推荐代码 查看2588 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$568 $ms] 淡意的温柔 606327 2020-07-09 15:29:06
内存最少[$2020 $KB] 刘欢@计算机科学与技术161 269288 2018-08-07 21:34:34
第一AC 刘欢@计算机科学与技术161 269288 2018-08-07 21:34:34
第一挑战 刘欢@计算机科学与技术161 269288 2018-08-07 21:34:34

赛题来源/所属竞赛 HDU N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛