Problem:
Score : 500 points

Problem Statement

Let S(n) denote the sum of the digits in the decimal notation of n.
For example, S(123) = 1 + 2 + 3 = 6.

We will call an integer n a Snuke number when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.

Given an integer K, list the K smallest Snuke numbers.

Constraints

1 \leq K

The K-th smallest Snuke number is not greater than 10^{15}.

Input

Input is given from Standard Input in the following format:

K

Output

Print K lines. The i-th line should contain the i-th smallest Snuke number.

Sample Input 1

10

Sample Output 1

1
2
3
4
5
6
7
8
9
19

Solution in Python (3.4.3) (judge verdict: Time Limit Exceeded)

def keta(n):
    ans = 0
    while n != 0:
        ans += 1
        n // 10
    return ans

def su(n):
    ans = 0
    while n != 0:
        ans += n % 10
        n = n // 10
    return ans

def sunuke(n):
    s = su(n)
    if s == 0:
        return 0
    return n/s

def hantei(n1,n2):
    if sunuke(n1) <= sunuke(n2):
        return 1
    else:
        return 0

def insert(k):
    ans = [1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99]
    while len(ans) < k:
        p = 3
        q = 0
        while (p-q-3) >= 0:
            n1 = int('1' + '0'*(p-2-q) + '9'*(q+1))
            n2 = int('1' + '0'*(p-3-q) +'1'+ '9'*(q+1))
            while hantei(n1,n2) == 1:
                ans_temp = [num for num in range(n1, n1+1+int(9*pow(10,q+1)),int(pow(10,q+1)))]
                for a in ans_temp:
                    ans.append(a)
                n1 += int(pow(10,p-1))
                n2 += int(pow(10,p-1))
            if (p-3-q) == 0:
                n0 = int('1'+'9'*(p-1))
                ans_temp = [num for num in range(n0, int(pow(10, p)), int(pow(10, p-1)))]
                for a in ans_temp:
                    ans.append(a)
            else:
                q += 1
        p += 1
    return ans
k = int(input())
ans = insert(k)
i = 0
while i < k:
    print(ans[i])
    i += 1