Basic Question

Revision en1, by suru1206, 2021-01-26 21:25:39

Sourav has an array A consisting of N integers(1-based indexing), He asks you to perform the following operation M times: for i=2 to n;

A[i]=A[i]+A[i-1]

Your task is to find the xth element of the array(i.e., A[x]) after performing the above operation M times. As the answer could be large, please output it modulo 10^9+7.

INPUT The First line of input contains an integer T denoting the number of test cases. The first line of each test case contains three space-separated integers-N,x,M-denoting the size of the array ,index of the element you have to find, and the amount of times you need to repeat operation before finding the element ,respectively.The second line contains N space-separated integers A1,A2,...,A[N].

OUTPUT For each test case,output a single line containing one integer : A[x]modulo 10^9+7.

CONSTRAINTS

1<=T<=10

1<=x<=N<=10^5

1<=M<=10^18

1<=A[i]<=10^18

EXAMPLE

Input:

2

3 2 3

1 2 3

3 3 3

1 2 3

Output:

5

15

#### History

Revisions

Rev. Lang. By When Δ Comment
en1 suru1206 2021-01-26 21:25:39 1019 I done this problem in O(m*n) for smaller values can anyone tell me to do in O(n) time complexity. (published)