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


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
	//変数の宣言
	int n;
	int k,s;
	long long int temp;
	long long int temp1;
	long long int temp2;
	int i,j;
	double sunuke1,sunuke2;
	int count;
	
	//データの読み込み
	scanf("%d",&n);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	count=0;
	k=1;
	s=1;
	while(count<=9){
		printf("%d\n",count);
		count++;
		if(count==n) return 0;
	}
	while(1){
		if(k%10!=0){
			k=k+1;
			temp=k;
			for(i=0;i<s;i++){
				temp=temp*10;
			}
			printf("%d\n",temp-1);
		}else{
			temp=k+1;
			for(i=0;i<s;i++){
				temp=temp*10;
			}
			temp=temp-1;
			temp1=temp;
			j=0;
			while(temp>0){
				j=j+temp%10;
				temp=temp/10;
			}
			sunuke1=(double)temp1/j;
			
			temp=k/10+1;
			for(i=0;i<s+1;i++){
				temp=temp*10;
			}
			temp=temp-1;
			temp2=temp;
			j=0;
			while(temp>0){
				j=j+temp%10;
				temp=temp/10;
			}
			sunuke2=(double)temp2/j;
			
//			printf("temp1=%lld,sunuke1=%lf,temp2=%lld,sunuke2=%lf\n",temp1,sunuke1,temp2,sunuke2);
			
			if(sunuke1<=sunuke2){
				k=k+1;
				printf("%lld\n",temp1);
			}else{
				k=k/10+1;
				s=s+1;
				printf("%lld\n",temp2);
			}
		}
		count++;
		if(count==n) return 0;
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
//	printf("結果の出力終了\n");
	
}