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 Scala (2.11.7) (judge verdict: Wrong Answer)

object Main extends App {
  def sunuke(i:Long) = {
    var temp = i
    var sunuke = 0L
    while (temp>0){
      sunuke = sunuke + (temp%10)
      temp = temp/10
    }
    sunuke
  }
  def judge(n:Long) = {
    val sunukeN = sunuke(n)
    val diff = 9-n%10
    if (n*(sunukeN+diff)<=(n+diff)*sunukeN){
      true
    } else {
      false
    }
  }
  val sc = new java.util.Scanner(System.in)
  val k = sc.nextLong()
  var counter = 0
  var current = 1
  while (counter < k){
    if (judge(current)){
      println(current)
      counter = counter + 1
    }
    current = current + 1
  }
}