DMOPC '18 Contest 2 P5 - Another Sequence Problem

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 1.4s
Memory limit: 256M

Author:
Problem type

Bob is investigating properties of integer sequences in an attempt to solve George's least favourite problem: Maintaining A Sequence!

To help Bob achieve his dreams, George gives Bob a warm up problem:

How many ordered sequences of N non-negative integers are such that each element is a member of the set {a1,a2,,aK} and whose sum is at most M?

Bob points out that this number might be a bit large, so George lets him return the answer modulo 109+7.

Can you help Bob solve his warm up problem?

Constraints

For all subtasks:

0akM

Each ai is guaranteed to be pairwise distinct.

Subtask 1 [20%]

1N,M,K500

Subtask 2 [20%]

ak=k1 for all 1kK

K=M

1N1018

1M,K2500

Subtask 3 [20%]

1N1018

1M,K500

Subtask 4 [40%]

1N1018

1M,K2500

Input Specification

The first line of input will contain three space separated integers, N, M, and K.
The second line of input will contain K space-separated integers, a1,a2,,aK.

Output Specification

The number of sequences that satisfy the given conditions, modulo 109+7.

Sample Input

Copy
2 3 4
1 3 2 0

Sample Output

Copy
10

Explanation for Sample

The possible sequences are: [0,0], [0,1], [0,2], [0,3], [1,0], [1,1], [1,2], [2,0], [2,1], and [3,0].


Comments

There are no comments at the moment.