One, two, not three
Easy
Execution time limit is 2 seconds
Runtime memory usage limit is 64 megabytes
A year ago, the infamous gangster Yurko decided he was done with robbing banks for large, round sums. Over the past year, he has been stealing amounts from banks that consist solely of the digits 1 and 2. After each heist, Yurko distributes the stolen amount equally among the N members of his gang. As a new member of Yurko's gang, you're curious to find out the smallest amount he can steal that can be evenly divided by N.
Input
A single integer N (1 ≤ N ≤ 10^6
).
Output
Print the smallest number composed only of the digits 1 and 2 that is divisible by N. If no such number exists or if its length exceeds 16 digits, print "Impossible".
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 228
Acceptance rate 15%