시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
0.35 초 | 1024 MB | 0 | 0 | 0 | 0.000% |
Being tired of shooting his huge upcoming movie, Deadpool has decided to take a short break and open a restaurant in Canada. Deadpool is also the chef and he can only cook one type of food: chimichangas. For those of you who don't know what chimichangas are (shame on you!), think of a fried burrito.
Deadpool can cook N unique types of chimichangas, each of them having a precise number of calories (Deadpool doesn't make mistakes). All the chimichangas have at most C calories.
The restaurant has become very popular. Today there are Q clients in line and Deadpool wants to impress them.
Each client eats a K-course meal (K dishes), follows a very strict diet and knows exactly how many calories they are supposed to eat. Client i eats exactly meali calories. Each client would like to know in how many ways they can achieve the amount of calories their diet requires by eating exactly K chimichangas (not necessarily of distinct types).
Given the calorie contents of N types of chimichangas (calorie1, calorie2, …, calorieN), as well as the number of courses K, you must answer Q questions, one for every client's calorie requirement.
The input has the format:
line 1: N K line 2: calorie1 calorie2 ... calorieN line 3: Q line 4 ... Q + 3: meal1 meal2 ... mealQ
The output must contain Q lines. Each line must contain a single number, the answer to the corresponding question. Because the answer can be big, you are asked to compute it modulo 2999.
번호 | 배점 | 제한 |
---|---|---|
1 | 20 | N ≤ 100, K ≤ 10, W ≤ 2,000 and C ≤ 500 |
2 | 5 | K = 2, W ≤ 60,000 and Q ≤ 100 |
3 | 25 | C × K ≤ 10,000 and W ≤ 50,000 |
4 | 20 | C × K ≤ 30,000 |
5 | 30 | none |
3 4 1 2 5 3 5 4 8
4 1 5
There are 4 ways to eat 5 calories: (1 + 1 + 1 + 2), (1 + 1 + 2 + 1), (1 + 2 + 1 + 1), (2 + 1 + 1 + 1).
There is 1 way to eat 4 calories: (1 + 1 + 1 + 1).
There are 5 ways to eat 8 calories: (1 + 1 + 1 + 5), (1 + 1 + 5 + 1), (1 + 5 + 1 + 1), (5 + 1 + 1 + 1), (2 + 2 + 2 + 2).