首页 > ACM题库 > HDU-杭电 > Hdu 1899 Sum the K-th’s 待解决 [解题报告] C++
2013
12-23

Hdu 1899 Sum the K-th’s 待解决 [解题报告] C++

Sum the K-th’s

问题描述 :

N integers are arranged on a circle clockwise. Given two integers M & K. For each position, you should take M continuous integers on the left and M continuous integers on the right. Take out the K-th number of the 2M integers. Then you will get N integers. Add all the integers up and tell me the sum. If the answer is not smaller than 1,000,000,007, divide it by 1,000,000,007 and tell me the remainder.

输入:

There is an Integer T in the first line. Which means the number of test cases in the input file. Then followed by T test cases.
For each test case, in the first line there are 3 Integers N(5<=N<=100,000),M(0<M*2<N),K(0<K<=2*M). Then there are N Integers, all the integers are non-negative Integers and smaller than 1,000,000,000.

输出:

For each test case, output the answer for a line.

样例输入:

2
5 2 2
1 2 3 4 5
5 1 2
1 2 3 4 5

样例输出:

12
21


  1. 题目需要求解的是最小值,而且没有考虑可能存在环,比如
    0 0 0 0 0
    1 1 1 1 0
    1 0 0 0 0
    1 0 1 0 1
    1 0 0 0 0
    会陷入死循环