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 Rust (1.42.0) (judge verdict: Wrong Answer)

use proconio::input;

fn rational_le(x: (u64, u64), y: (u64, u64)) -> bool {
    (x.0 as f64) / (x.1 as f64) <= (y.0 as f64) / (y.1 as f64)
}

fn cal(mut x: u64) -> f64 {
    let mut num = x;
    let mut den = 0;
    while 0 != x {
        den += x % 10;
        x /= 10;
    }
    num as f64 / den as f64
}

fn main() {
    let mut cand = vec![];
    for head0 in 0..10 {
        for head1 in 0..10 {
            let mut geta = 1u64;
            for tail_len in 0..=16 {
                cand.push((
                    (head0 * 10 + head1 + 1) * geta - 1,
                    head0 + head1 + 9 * tail_len,
                ));
                geta *= 10;
            }
        }
    }
    cand.sort_by_key(|&(x, _)| std::cmp::Reverse(x));
    cand.dedup();

    let mut snuke = vec![];
    let mut min = (1, 0);
    for (x, y) in cand {
        if rational_le((x, y), min) {
            snuke.push(x);
            min = (x, y);
        }
    }
    snuke.reverse();

    input!(k: usize);
    for x in snuke.iter().take(k) {
        println!("{}", x);
    }
}