ONEZERO  Ones and zeros
Certain positive integers have their decimal representation consisting only of ones and zeros, and having at least one digit one, e.g. 101. If a positive integer does not have such a property, one can try to multiply it by some positive integer to find out whether the product has this property.
Input
Number K of test cases (K is approximately 1000);
in each of the next K lines there is one integer n (1 <= n <= 20000)
Output
For each test case, your program should compute the smallest multiple of the number n consisting only of digits 1 and 0 (beginning with 1).
Example
Input: 3 17 11011 17 Output: 11101 11011 11101
hide comments
babur:
20170627 07:02:14
Weak Test Cases.... 

himmi97:
20170607 11:10:13
weak test cases..try 999 and 9999.


codervrinda:
20170525 13:30:33
@vipul_8 check for larger numbers...


vipul_8:
20170525 11:13:15
can someone help.. why i'm getting wrong answer for this code http://ideone.com/U0MLF8 

candide:
20170501 10:13:44
Can also be solved with dynamic programming, but it's slow, about 0.16s. Last edit: 20170501 22:05:28 

sucide:
20170404 00:43:28
Ac in one go :)


rishi_07:
20170328 23:57:12
Great question! 

anup108:
20170322 11:52:20
answer for 999? 

yashrocks22:
20170226 19:46:53
AC in a single go!!,use array representation to store the whole tree and backtrack using bfs.. Last edit: 20170226 20:20:51 

prasoonbatham:
20170120 15:26:54
Great question on bfs :) 
Added by:  PaweÅ‚ Dobrzycki 
Date:  20050526 
Time limit:  8s 
Source limit:  4096B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 VB.NET 
Resource:  II Polish Olympiad in Informatics, Ist Stage 