Count CGPA range tables with equal widths and arithmetic rates that spend exactly P units on the given students.
Medium7Brute forceMathPrefix sumNo attempts yetTime limit4sMemory limit256 MBA university gives scholarships based on each student's CGPA. At the start of a semester it posts a table of scholarship rates by CGPA range. Here are two such tables.
| CGPA range | Scholarship rate |
|---|---|
| 4.00-4.00 | 50% |
| 3.90-3.99 | 40% |
| 3.80-3.89 | 30% |
| 3.70-3.79 | 20% |
| 3.60-3.69 | 10% |
| CGPA range | Scholarship rate |
|---|---|
| 3.91-4.00 | 80% |
| 3.71-3.90 | 50% |
| 3.51-3.70 | 20% |
The first table says that a student whose CGPA is between 3.60 and 3.69 receives 10% of the tuition fee as a scholarship. In the same way a student whose CGPA is between 3.90 and 3.99 receives 40%. The rules for such a table are:
CGPA values and range boundaries are multiples of 0.01 between 0.00 and 4.00.
You are given the number of students, the number of units to spend, and the CGPA of every student. Count the different scholarship tables that spend exactly P units. Two tables are different if their CGPA ranges differ, or if any range carries a different rate.
The input holds at most 100 test sets.
The first line of each set has the number of students N (1≤N≤10000) and the number of units to spend P (1≤P≤1000000), separated by a space. Each of the next N lines has the CGPA of one student, written with two digits after the decimal point. A CGPA is between 0.00 and 4.00.
The last line of the input holds two zeros and is not processed. Every set admits at least one table that spends exactly P units.
For each test set print one line with D, the number of different scholarship tables that spend all P units.
In the first example, take 2.88-3.02 as the lowest range and continue with that width up to 4.00. That gives eight ranges. A lowest rate of 10% with a step of 10% produces the table below.
| CGPA range | Students | Scholarship rate | Units needed |
|---|---|---|---|
| 3.93-4.00 | 2 | 80% | 160 |
| 3.78-3.92 | 0 | 70% | 0 |
| 3.63-3.77 | 3 | 60% | 180 |
| 3.48-3.62 | 0 | 50% | 0 |
| 3.33-3.47 | 0 | 40% | 0 |
| 3.18-3.32 | 2 | 30% | 60 |
| 3.03-3.17 | 0 | 20% | 0 |
| 2.88-3.02 | 1 | 10% | 10 |
The total is 410 units. Another 79553 tables spend those 410 units exactly.