|
||||||||||
Integers¡¯ WeightTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 314 Accepted Submission(s): 95 Problem Description The weight of a positive integer is the sum of its digits. For example, weight(12097) = 1+2+0+9+7 = 19. For any positive integer x, f(x) = 1 if weight(x) = x, and f(x) = f(weight(x))+1 otherwise. For example, f(2) = 1 and f(654) = f(15)+1 = f(6)+1+1 = 3. Find the smallest number x that f(x) = n. The answer may be huge, just output the remainder after divided by 100007. Input There are several test cases in the input. Each test case begin with an integer n (1 <= n <= 1000000000). The input terminates by end of file marker. Output For each test case, output the result in a single line. Sample Input
Sample Output
Author hanshuai Source | ||||||||||
|