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: Time Limit Exceeded)

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

int main(){
  int K,SN =0, N = 1;
  int i = 0, j, k,  work;
  int ans[100000] ={};
  double ans_calc[100000]={};
  ans_calc[0] = 100;
  double calc;
  scanf("%d", &K);

  while(i< K * 2){
    SN = 0;
    work = N;
    for(k=0;work!=0;k++){
      SN +=work % 10;
      work = work /10;
    }
    calc = (double)N/(double)SN;


    if(calc < ans_calc[i]){
      //check and put to ans
      for(j=0;j<i+1;j++){
        if(ans_calc[j]>calc){
          ans[j] = N;
          ans_calc[j] = calc;
          i = j;
          //printf("break");
          break;
        }
      }
    }else if(calc == ans_calc[i]){
      i++;
      ans[i]= N;
      ans_calc[i] = calc;
      //printf("N=%d i=%d\n", N, i);
    }else{
      i++;
      ans_calc[i] = calc;
      ans[i] = N;
    }

    //printf("N=%d %f i=%d k=%d\n",N, calc, i, k);
    //next N is...
    if(N<9){
      N++;
    }else{
      N +=10;
    }
  }
  for(i = 0; i<K; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}