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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long k = sc.nextLong();
		//
		//	
		//		for(int i = 1000;i <= 2000;i++){
		//			int S = 0;
		//			if(i <= 9){
		//				S = i;
		//			}else if(i > 9 && i < 100){
		//				S = i/10;
		//				S = S + (i - S*10 );
		//			}else{
		//				S = i/100;
		//				int SS = 0;
		//				SS = i - S*100;
		//				S = S + (SS/10) + (SS - SS/10*10);
		//			}
		//				System.out.println("i " + i+" S "+ S+" sunuke "+ (double)((double)i / S));
		//			
		//		}
		long count = 0;
		long sunukenum = 1l;
		

		while(true){
			if(count == k){
				return;
			}
			System.out.println(sunukenum);
		
			int keta = String.valueOf(sunukenum).length();
			long sunuke = Long.MAX_VALUE;
		//	System.out.println(sunuke);8
			long karinext = 0l;
			for(int i = 0;i <= keta;i++){
				long karin = sunukenum + (long)Math.pow(10, keta-i);
		//		System.out.println("karin "+karin);
//				System.out.println("sum "+sum(karin));

				long karisunuke = karin / sum(karin);
				if(sunuke > karisunuke){
					sunuke = karisunuke;
					karinext = karin;
				}	
			}
			sunukenum = karinext;	
			count++;
			
		}



	}
	static long sum(long n){
		long l =  String.valueOf(n).length();
		long s = 0l;
		for(int i = 0;i < l;i++){
			s +=  (long)(n/Math.pow(10, l-1-i));
			n -= (long)Math.pow(10, l-1-i) *(long)(n/Math.pow(10, l-1-i));
		}
		
		return s;
		
		
	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}