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 OCaml (4.02.3) (judge verdict: Wrong Answer)

let rec s = function
  | 0 -> 0
  | n -> n mod 10 + s (n / 10)

let p x y = x * s y <= y * s x

let bases = Array.to_list @@ Array.init 16 (fun d -> int_of_float (10. ** float_of_int d))

let solutions =
  Array.init 1000 (fun i ->
    List.filter (fun r ->
      p ((i + 1) * r - 1) ((i - i mod 10 + 10) * r - 1) &&
      p ((i + 1) * r - 1) ((i - i mod 100 + 100) * r - 1) &&
      p ((i + 1) * r - 1) ((i - i mod 1000 + 1000) * r - 1)) bases
    |> List.map (fun r -> (i + 1) * r - 1))
  |> Array.to_list
  |> List.concat
  |> List.sort_uniq compare
  |> Array.of_list

let () = Scanf.scanf "%d" @@ fun k ->
  for i = 1 to k do
    Printf.printf "%d\n" solutions.(i - 1)
  done