영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
The French gourmet Frank is a very well-respected gourmet; his job involves going around to various restaurants, eating their food and then writing a review about the restaurant. But he carries a dark secret: he is actually only interested in eating as much as possible and in any order!
However, Frank understands that a true gourmet can't eat in just any manner, like starting with his dessert and finishing with a salad. Therefore, he asks for your help in constructing a list with all the different ways he could arrange his courses during a meal, so that he can pick the best order.
During the serving, Frank has M minutes to eat. The restaurant offers N different courses, and he can eat any number of servings of each course. For course i, it takes T_i minutes to eat a serving of it. Frank wants to eat something during each of the M minutes he has, and he wants to finish every course that he is served. He never wants to start eating a new course until he finished the last one.
Your task is to write a program to compute the number of ways he could arrange his meal, given these restrictions.
Input
The first line contains an integer M (1 ≤ M ≤ 1000), the number of minutes.
The second line contains an integer N (1 ≤ N ≤ 30), the number of courses.
Afterwards, N lines follow with an integer T_i (1 ≤ T_i ≤ 200) on each line, the time it takes to eat every dish.
Output
The program should output the number of ways in which Frank can eat during exactly M minutes.
The answer will always be at most 2 billion (2000000000).
Scoring
Your solution will be tested on a set of test case groups. To get the points for a group, you need to pass all the test cases in the group.
| Group | Point value | Constraints |
|---|---|---|
| 1 | 60 | The answer will be less than 2 million (2000000). |
| 2 | 40 | No additional constraints. |
Explanation of Sample 1
Frank is going to eat during 10 minutes and have two courses to choose from, for example a salad (takes 3 minutes to eat) and pie (7 minutes). There are only two ways he can eat them: first pie and then salad or vice versa. If he only eats salad he will either finish too quickly (3 servings = 9 minutes) or too late (4 servings = 12 minutes).
예제
예제 1
10 2 7 3
2
예제 2
12 6 1 3 3 5 6 12
498