The Easiest Problem Is This One
Time limit1sMemory limit128 MB
For each positive integer N up to 100000, find the smallest multiplier p greater than 10 such that N and N*p have the same decimal digit sum.
- Level
Easy3 of 10
- Topics
- Brute force, Math, Implementation, Number theory
- Solved
- No attempts yet
Problem
Write a positive integer in the decimal system as a sequence of digits.
Each digit contributes a value multiplied by a power of .
The digit sum is the plain sum of the digits, without multiplying by any power of .
For example, if then .
Multiplying by another number usually changes the digit sum. For example, with :
However, some multipliers leave the digit sum unchanged. For example, with :
Find the smallest positive integer that is greater than and satisfies .
Input
The input consists of several test cases. Each test case is a single line containing one positive integer , where . The last test case is followed by a line containing a single , which is not processed.
Output
For each test case, print on its own line the smallest integer greater than for which .