Na2a and lucky stone
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
A number is called as a lucky number if its decimal representation contains only the lucky digits, 4 and 7. e.g. 47, 744, 4 are lucky numbers, whereas 5, 17, 467 are not.
Recently, Na2a found a magic stone. With the help of this stone, he can multiply a number by any lucky number. Also, the magic stone can be used any number of times (possibly zero or infinite number of times).
For example, if initially he has the number 1, then he can get numbers like 28 (formed by 1*4*7), 14476 (formed as 1*47*77*4) etc.
Na2a has N numbers in his bag which are denoted by array A. For each number Ai in his bag, he asks you to transform it to a number with maximum possible number of trailing zeroes by using Magic Stone. You have to find the smallest of such numbers, since there can be multiple numbers with the maximum possible number of trailing zeros.
- There is a single test case.
- First line contains a single integer N as stated in the problem.
- The second line contains N space-separated integers A1, A2, ... , AN where Ai denotes the ith number in the bag.
- Output N lines, in which ith line contains the answer corresponding to the number Ai.
- 1 ≤ N ≤ 105
- 1 ≤ Ai ≤ 109
Subtask 1(8 points)
- 1 ≤ N ≤ 10
- 1 ≤ Ai ≤ 10
Subtask 2(22 points)
- 1 ≤ N ≤ 102
- 1 ≤ Ai ≤ 103
Subtask 3(70 points)
- Original constraints
Input: 2 2 15 Output: 2 60
Example case 1. You can't get any number having zeros at the end multiplying 2 by lucky numbers.
Example case 2. You can multiply 15 by 4 and get 60, which has one trailing zero.
|Tags||july15, maths, na2a, simple|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.