Inaho IX

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 64M

Authors:
Problem type

Inaho is given a function:

f(x)={a1f(x1)+a2f(x2)++aNf(xN)if x>N1if xN

Given N,Z and a, Inaho wants you to print f(Z)mod109+7.

Input Specification

The first line will contain two integers, N,Z (1N10,1Z<1010000).

The second line will contain N integers, a1,a2,,aN (1ai106).

Output Specification

Print f(Z)mod109+7.

Subtasks

Subtask 1 [10%]

Z<105

Subtask 2 [30%]

Z<1018

Subtask 3 [60%]

No additional constraints.

Sample Input 1

Copy
2 5
1 1

Sample Output 1

Copy
5

Sample Input 2

Copy
6 90000
4 2 29 5 1 10

Sample Output 2

Copy
408918679

Comments

There are no comments at the moment.