ADADIG - Ada and Digits
As you might already know, Ada the Ladybug is a farmer and she also loves math. One day, as farming is sometimes very notorious work, she was thinking about numbers. She was wondering about how many numbers there are having exactly same digital sum as digital product.
She have found out some answers for small N (sum & product), but then the numbers started getting big. Can you help her to find out the answers for bigger sums to satisfy her mind?
The first line contains a single integer 1 ≤ T ≤ 100, number of test-cases.
Each of the next line contains a single number 1 ≤ N ≤ 3*105 , the required sum (and so the required product).
For each test-case, print the number of existing numbers. Since this number might be pretty huge, output it modulo 109+7 (1000000007).
8 1 2 3 7 8 12 16 144
1 1 1 1 23 240 1091 243368058
Nice problem XD. I got many TLEs because of wrong approachLast edit: 2017-09-16 18:49:37
@gokul_prasanth: Good day to you
@gokul you need to output number of numbers having sumOfDigits=ProductOfDigits ,say for each prime only the number itself is the sum and product of itself so answer for all primes is 1 and if it is more than 1 digit number it wud be 0Last edit: 2017-09-16 06:15:21
@morass can you please explain the problem??
@[Rampage] Blue.Mary: Right, firstly I aimed for "easier" solution so I've let the constraints to be low :/ Anyway if you think I'm missing some kind of worst-case (or why it is unexpected?) or it deserves another "hard" version with bigger constraints (or so) tell me ^_^
Unexpected 0.00 second AC...