Home STD Contest Notification Clarification Problems Ranklist Status Print Sign Out

Kykneion asma

Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 13    Accepted Submission(s): 6


Problem Description
On the last day before the famous mathematician Swan's death, he left a problem to the world: Given integers $n$ and $a_i$ for $0\leq i \leq 4$, calculate the number of $n$-digit integers which have at most $a_i$-digit $i$ in its decimal representation (and have no $5,6,7,8$ or $9$). Leading zeros are not allowed in this problem.
 

Input
There is one integer $T~(1<T\le 10)$ in the beginning of input, which means that you need to process $T$ test cases. In each test case, there is one line containing six integers representing $n$ and $a_0$ to $a_4$, where $2\leq n\leq 15000$ and $0\leq a_i\leq 30000$.
 

Output
For each test case, you should print first the identifier of the test case and then the answer to the problem, module $10^9+7$.
 

Sample Input
10 5 0 1 2 3 4 5 1 1 1 1 1 5 2 2 2 2 2 5 3 3 3 3 3 5 3 2 1 3 2 5 3 2 0 0 0 5 0 0 0 5 0 7000 41 2467 6334 2500 3169 7000 7724 3478 5358 2962 464 7000 5705 4145 7281 827 1961
 

Sample Output
Case #1: 535 Case #2: 96 Case #3: 1776 Case #4: 2416 Case #5: 1460 Case #6: 4 Case #7: 1 Case #8: 459640029 Case #9: 791187801 Case #10: 526649529
 

Statistic | Submit | Clarifications | Back