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: Accepted)

#include<iostream>
#include<vector>
#define ll long long
using namespace std;

vector<int>decompose(ll x){
	vector<int>tmp;
	while(x)tmp.push_back(x%10),x/=10;
	return tmp;
}

ll to_number(vector<int>x){
	ll tmp=0;
	for(int i=x.size()-1;~i;--i)
	(tmp*=10)+=x[i];
	return tmp;
}

ll sum(ll x){
	ll s=0;
	while(x)s+=x%10,x/=10;
	return s;
}

inline ll f(ll x){
	vector<int>dx=decompose(x);
	double mn=1e18;ll ne=-1;
	for(int i=0;i<dx.size();++i){
		for(int d=dx[i];d<=9;++d){
			vector<int>dy=dx;
			dy[i]=d;
			for(int j=0;j<i;++j)dy[j]=9;
			ll y=to_number(dy),sy=sum(y);
			if((double)y/sy<mn)
				mn=(double)y/sy,ne=y;
		}
	}
	return ne;
}

int k;

void solve(){
	ll s=1;
	for(int i=1;i<=k;++i,s=f(s+1))
		cout<<s<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin>>k;
	solve();
	return 0;
}