Barcode
Practice
3.9 (12 votes)
Dynamic programming
Combinatorics
Easy Medium
Ready
Mathematics
Open
Approved
Problem
48% Success 2819 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You have n-strip colorless bar code, where each strip is of unit length. You are given k brushes having their own different width. Using a brush of width w you can paint at a time exactly w consecutive strips on a bar code with black color, with the condition that initially all those w strips should be colorless. You can use any brush infinite times.

Find the number of distinct bar codes that you can create. Two bar codes are considered different if there exists at least one strip that is black in first and colorless in other. Print your answer modulo 109+7.

Input:

First line of input contains two space separated integers n and k denoting number of strips on bar code and number of brushes respectively. Next line contains k space separated integers, the ith integer denoting the width of ith brush.

Output:

Output in single line, your answer modulo 109+7.

Constraints:

1 ≤ n , k ≤ 103
1 ≤ width of ith brush (wi) ≤ 103

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
Easy-Medium
Points:30
2 votes
Tags:
Dynamic ProgrammingAlgorithmsApprovedEasy-Medium
Points:30
Tags:
Easy-Medium