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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;

namespace ARC099D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());

            long max = (long) Math.Pow(10, 15);
            Dictionary<long, double> rates = new Dictionary<long, double>();
            for (long i = 1; i < max;)
            {
                rates.Add(i, Rate(i));
                i += Math.Max((long) Math.Pow(10, Digit(i + 1) - 4), 1);
            }

            List<long> keyList = new List<long>(rates.Keys);
            keyList.Reverse();
            double min = max;

            List<long> ans = new List<long>();
            foreach (long index in keyList)
            {
                if (min >= rates[index])
                {
                    ans.Add(index);
                    min = rates[index];
                }
            }

            ans.Reverse();
            for (int i = 0; i < k; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }

        public static int Digit(long n)
        {
            return n == 0 ? 1 : (int) Math.Log10(n) + 1;
        }

        public static double Rate(long n)
        {
            long temp = n;
            long sn = 0;
            while (temp > 0)
            {
                sn += temp % 10;
                temp /= 10;
            }

            return (double) n / sn;
        }
    }
}