Submit | All submissions | Best solutions | Back to list |
NUMTSN - 369 Numbers |
A number is said to be a 369 number if:
- The count of 3s is equal to the count of 6s and the count of 6s is equal to the count of 9s.
- The count of 3s is at least 1.
For Example 12369, 383676989, 396 all are 369 numbers whereas 213, 342143, 111 are not.
Given A and B find how many 369 numbers are there in the interval [A, B]. Print the answer modulo 1000000007.
Input
The first line contains the number of test cases (T) followed by T lines each containing 2 integers A and B.
Output
For each test case output the number of 369 numbers between A and B inclusive.
Constraints
T ≤ 100
1 ≤ A ≤ B ≤ 1050
Example
Input: 3 121 4325 432 4356 4234 4325667 Output: 60 58 207159
Added by: | Saransh Bansal |
Date: | 2012-03-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
|||||||
2014-06-11 22:42:54 David
I'm using a dp table dp[51][18][18][18][2] and getting TLE. Is the dimension of the table correct? or am i doing this completely wrong? |
|||||||
2014-06-04 10:34:23 ABHISHEK004
really an awesome problem!!!!!! made my day :) Accepted after so many tle's and wrong answers... thanks to the problem setter for such a problem.. learnt new things from this :D |
|||||||
2014-05-20 10:10:47 yrocks
this problem cannot be solved in Python coz, range function cannot go till 10^50 |
|||||||
2012-10-06 10:24:49 (Tjandra Satria Gunawan)(曾毅昆)
Silly mistake, I forgot about mod m, finally AC ;-) Nice problem... |
|||||||
2012-06-30 20:15:16 devu
Finally Accepted!! Learned a lot and thnxs a lot for the problem!! Last edit: 2012-06-24 19:30:53 |
|||||||
2012-06-30 20:15:16 Saransh Bansal
Thanks a lot.. for your comments :) |
|||||||
2012-06-30 20:15:16 Ehor Nechiporenko
Realy Awesome problem!!! :)) |
|||||||
2012-06-30 20:15:16 #vaidy_MIT#
awsme problem ...:) |