Average
Time limit1sMemory limit512 MB
Count, over all N-tuples of integer marks from 0 to fullmarks, the total number of teachers whose mark equals the tuple's mean, modulo 1000000007.
- Level
Medium7 of 10
- Topics
- Combinatorics, Dynamic programming, Math
- Solved
- No attempts yet
Problem
teachers grade one student's presentation. Each teacher gives one integer from 0 to fullmarks, inclusive. The student's final score is the arithmetic mean of these marks.
Every mark is an integer, but the mean can still be a fraction. Sometimes the mean is an integer, and in some of those cases a teacher's mark equals the mean exactly. One teacher whose mark equals the mean is called a matching event.
Consider every combination of marks the teachers can give. If teachers gave a mark equal to the mean in one combination, that combination produces matching events. Count the total number of matching events over all combinations.
Input
The input holds several test cases, at most 1001 of them.
Each test case is one line with two integers and fullmarks, where and . is the number of teachers grading the student, and fullmarks is the largest mark a teacher can give. The smallest mark a teacher can give is always 0.
A line holding two zeros ends the input. Do not process that line.
Output
For each test case, print one line holding modulo , where is the total number of matching events.