Problem 2587 --Period Sequence

2587: Period Sequence

"
Time Limit $6$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $4$ 正确数量 $3$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Chiaki has n integers s0,s1,…,sn−1. She has defined an infinite sequence S in the following way: Sk=skmodn+n⋅⌊kn⌋, where k is a zero based index.

For a continuous subsequence S[l..r], let cntx be the number of occurrence of x in the subsequence S[l..r]. Then the value of S[l..r] is defined as follows
f(l,r)=∑xx⋅cnt2x


For two integers a and b (a≤b), Chiaki would like to find the value of
(∑a≤l≤r≤bf(l,r))mod(109+7)
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains three integers n, a and b (1≤n≤2000,0≤a≤b≤1018).
The second line contains n integers s0,s1,…,sn−1 (0≤si≤109).
It is guaranteed that the sum of all n does not exceed 20000.

For each test case, output an integer denoting the answer.
4
3 2 6
2 1 3
5 2 7
2 1 5 1 2
4 4 8
2 1 5 17
3 5 9
2 5 2
179
268
369
437

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

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$563 $ms] 云朵 806963 2022-01-05 13:29:34
内存最少[$0 $KB] 淡意的温柔 606325 2020-07-09 15:28:26
第一AC 淡意的温柔 606325 2020-07-09 15:28:26
第一挑战 淡意的温柔 606325 2020-07-09 15:28:26

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

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