Product of Digits
All submissions for this problem are available.
The chef may be losing his mind. He has demanded you solve the following task:
given an integer P, find the smallest positive integer whose product of digits, modulo 1000000007, is P.
You can't imagine what this has to do with cooking, but you'd better do what he says or you won't get to sample his culinary delights.
Input will begin with a positive integer T<=15, the number of test cases.
T lines follow, each containing an integer P between 0 and 1000000006, inclusive.
For each test case, print on a single line the smallest positive integer whose product of digits, modulo 1000000007, is P.
It is guaranteed that such an integer exists with fewer than 700 digits.
4 16 486 220703118 0
28 699 5555555555555 10
|Tags||cook03, hard, pieguy|
|Time Limit:||2.48684 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.