Unusual Number
Time limit2sMemory limit512 MB
Given digit count a and multiplier b, find the smallest a-digit number whose last digit moved to the front equals b times the number, or report Impossible.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Implementation, Brute force
- Solved
- No attempts yet
Problem
A positive integer is an unusual number when it satisfies both of the conditions below.
- has digits and its leading digit is not 0.
- Let be the number formed by moving the last digit of to the front. Then .
Given and , find the smallest unusual number.
Input
The first line contains and , separated by a single space. (, )
Output
Print the smallest unusual number on the first line. If no number satisfies the conditions, print Impossible.