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 <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

// int s(int n)
// {
// 	int ans = 0;
// 	while(n > 0){
// 		ans += n % 10;
// 		n /= 10;
// 	}
// 	return ans;
// }

// double res[1010000];
// int ans[1010000];

// int main()
// {
// 	for(int i = 1; i <= 1000000; i++){
// 		res[i] = (i + 0.0) / (s(i) + 0.0);
// 	}
// 	ans[1000000] = 1000000;
// 	for(int i = 1000000 - 1; i >= 1; i--){
// 		if(res[i] <= res[ans[i + 1]]){
// 			ans[i] = i;
// 			cout << i << " " << ans[i] << " " << res[i] << endl;
// 		}
// 		else ans[i] = ans[i + 1];
// 	}
// }

int main()
{
	int k;
	cin >> k;
	for(int i = 0; i < 15; i++){
		if(k == 0) break;
		if(i > 2){
			for(long long int j = 0; j < 9; j++){
				if(k == 0) break;
				cout << (long long int)pow(10, i) + (j + 1) * (long long int)pow(10, i - 1) - 1 << endl;
				k--;
			}
		}
		for(long long int j = 1; j < 10; j++){
			if(k == 0) break;
			cout << (j + 1) * (long long int)pow(10, i) - 1 << endl;
			k--;
		}
	}
}