F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Integers¡¯ Weight

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 312    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
2 3
 

Sample Output
10 19
 

Author
hanshuai
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 20:26:46, Gzip enabled