Finding a Multiple
InterviewTime limit1sMemory limit128 MB
For each n up to 200, print the smallest multiple of n whose decimal digits are only 0 and 1, with up to 100 digits.
- Level
Medium6 of 10
- Topics
- BFS, Number theory, Math, String matching
- Solved
- No attempts yet
Problem
Given a positive integer , consider a positive integer that is a multiple of and whose decimal representation consists only of the digits 0 and 1. Such an always exists. Write a program that finds the smallest such .
Here is a positive integer of at most 200, and the smallest valid has at most 100 digits.
Input
The input consists of several test cases. Each line contains one integer (). The last line contains and must not be processed.
Output
For each test case, print on its own line the smallest that satisfies the condition.