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
letuantam96:
20190320 09:08:01
Great problem. A lot of optimizion you have to do. Got it in 0.22s. 

ab_biswas09:
20190121 15:01:48
Nice problem , BFS + MODULAR ARITHMATIC =AC Last edit: 20190121 15:02:03 

jmr99:
20181016 11:07:39
wow just wow !! *__* 

rajhim2:
20180722 14:15:05
If one is using C++ then for numbers like n=19999,19953, etc. the multiples will exceed the limit of int and eventually you will have to use string. You will have to create a separate function for longDivision. If one is using python then it is very easy problem for python users.


oneinchatatime:
20180603 19:19:57
Great problem!!


codeking123:
20180314 18:29:44
thanks to tarun 

tarun2619:
20180224 05:46:21
For optimizing bfs : https://www.geeksforgeeks.org/findthesmallestbinarydigitmultipleofgivennumber/ 

sagarstorm:
20180122 15:40:35
Nice problem, lot of things to take care of 

yashgulani:
20171107 21:20:34
test cases are weak , there is no test case having n=1 boundary condition . Please improve the test case for this particular question . 

aditya930:
20171020 15:47:04
getting WA can someone help wrong answer code is https://ideone.com/SMd9dj 
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 