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: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using static System.Console;
using static PB10004.Algorithm.Util;

namespace PB10004.Algorithm
{
    class Template
    {
        static void Main(string[] args)
        {
            new ABC101D().Solve();
        }
    }
    public class ABC101D
    {
        public void Solve()
        {
            var K = ReadLong();
            for(long i = 1; i <= Math.Min(K,9); i++)
            {
                WriteLine(i);
            }
            int keta = 1;
            while(keta <= 15)
            {
                for (long i = 2*(long)Math.Pow(10, keta); i <= Math.Min(K, Math.Pow(10,keta+1)); i += Math.Min(100,(long)Math.Pow(10,keta)))
                {
                    if (Eval(i-1) <= Eval((long)Math.Pow(10,keta+1)-1))
                        WriteLine(i-1);
                }
                keta++;
            }
        }
        public double Eval(long n)
        {
            return n * 1.0 / DigitSum(n);
        }
        public long DigitSum(long n)
        {
            long res = 0;
            var str = n.ToString();
            foreach(var chr in str)
            {
                res += long.Parse(chr.ToString());
            }
            return res;
        }
    }
    public class Problem14
    {
        long[] dp = new long[1000000];
        public void Solve()
        {
            for (long i = 999999; i > 1; i--)
            {
                var count = 0;
                var t = i;
                while (t != 1 && t < long.MaxValue)
                {
                    count++;
                    if (t % 2 == 0)
                    {
                        t /= 2;
                        if (t == 1) dp[i] = count;
                    }
                    else t = t * 3 + 1;
                    if (t < 999999)
                    {
                        if (dp[t] != default(long))
                        {
                            dp[i] = dp[t] + count;
                            break;
                        }
                    }
                }
            }
            WriteLine("{0},{1}", dp.Max(), SearchIndex(dp.Max()));
        }
        long SearchIndex(long key)
        {
            for (int i = 0; i < dp.Length; i++)
                if (dp[i] == key) return i;
            return -1;
        }
    }
    public static class Util
    {
        /// <summary>
        /// 標準入力をint型にパースする
        /// </summary>
        /// <returns></returns>
        public static int ReadInt()
        {
            return int.Parse(ReadLine());
        }
        /// <summary>
        /// 標準入力をint型の配列にする
        /// </summary>
        /// <returns></returns>
        public static int[] ReadIntArray()
        {
            return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }
        /// <summary>
        /// 標準入力をlong型にパースする
        /// </summary>
        /// <returns></returns>
        public static long ReadLong()
        {
            return long.Parse(ReadLine());
        }
        /// <summary>
        /// 標準入力をlong型の配列にする
        /// </summary>
        /// <returns></returns>
        public static long[] ReadLongArray()
        {
            return ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        /// <summary>
        /// 一定値の数列を生成する
        /// </summary>
        /// <param name="value"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static IEnumerable<long> ConstSeq(long value, long length)
        {
            for (int i = 0; i < length; i++)
            {
                yield return value;
            }
        }
        /// <summary>
        /// int配列の累積和を求める
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static IEnumerable<int> CumulativeSum(IEnumerable<int> array)
        {
            int tmp = 0;
            foreach (var num in array)
                yield return tmp += num;
        }
        /// <summary>
        /// long配列の累積和を求める
        /// </summary>
        /// <param name="array"></param>
        /// <returns></returns>
        public static IEnumerable<long> CumulativeSum(IEnumerable<long> array)
        {
            long tmp = 0;
            foreach (var num in array)
                yield return tmp += num;
        }
        /// <summary>
        /// 最大公約数をユークリッドの互除法で求める
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }
        /// <summary>
        /// 最小公倍数を求める
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }
    }
}