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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

long long k;

int sum(long long num) {
    int s = 0;
    while (num > 0) {
        s += num % 10;
        num /= 10;
    }

    return s;
}

int print(int digs) {

    if (k == 0) {
        return 0;
    }
    int nines = (digs >= 4 ? digs-2 : digs-1);

    if (digs == 1) {
        for (int z=1; z <= 9; z++) {
            cout << z << '\n';
            k--; if (k == 0) return 0;
        }

        return 0;
    }

    long long alln = 9;
    for (int r=1; r<digs; r++) {
        alln *= 10;
        alln *= 9;
    }

    long long nnn = 9;
    for (int r=1; r<nines; r++) {
        nnn *= 10;
        nnn += 9;
    }

    long long pow = 1;
    for (int z=1; z<digs-nines; z++) {
        pow *= 10;
    }

    long long pow_mult = 1;
    for (int r=0; r<nines; r++) {
        pow_mult *= 10;
    }

    for (long long z=pow; z<pow*10; z++) {

        long long zzz = z * pow_mult + nnn;

        if ((double)zzz/sum(zzz) <= (double)alln/sum(alln) + 1e-7) {
            cout << zzz << '\n';
            k--; if (k == 0) return 0;
        }
    }

}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> k;

    for (int j=1; j<=17; j++)
        print(j);


    return 0;
}