Sphere Online Judge

SPOJ Problem Set (classical)

370. Ones and zeros

Problem code: ONEZERO

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.


Number K of test cases (K is approximately 1000);
in each of the next K lines there is one integer n (1 <= n <= 20000)


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).



Added by:Pawe≥ Dobrzycki
Time limit:8s
Source limit:4096B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: NODEJS PERL 6
Resource:II Polish Olympiad in Informatics, Ist Stage

hide comments
2014-03-10 17:38:27 californiagurl
modular maths FTW :D (y) !!!!
hint: only one character array required
2014-01-21 18:38:58 Somesh Maurya™
ans for 19998??
2013-12-27 10:33:31 Srijan Khare
i think 9999 is not included in the test cases... anyway nice problem :)
2013-12-25 15:12:23 Gitanshu Behal
Finally Green Light :) Map and std:queues costed me 10+ TLEs....
2013-12-17 18:25:25 AKSHAT JAIN
Nice problem....avoid string

Last edit: 2013-12-18 05:39:51
2013-12-15 16:36:38 sam
very nice question!!
2013-10-25 12:50:34 aar
Very good question.. BFS.. Must solve.. Solved in 9 hrs, but was worth...
2013-09-22 07:57:42 SkAd@@sh2
Have an optimized I/O and some tricks up sleeve to get AC ... btw dont need strings for and it keep it simple ... excellent problem , spent 6 hours on it and enjoyed .. XD.
2013-03-17 10:13:02 ginnipkj
don't use strings....
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.