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 Ruby (2.3.3) (judge verdict: Wrong Answer)


def digit_sum(n)
  n.to_s.each_char.map {|c| c.to_i }.reduce(:+)
end

K = gets.to_i
#res  = []
#100000.times{|i|
##  res << (i+1)/digit_sum(i+1).to_f
#}
#puts res
res = [*1..9]
res = res.concat([*1..9].map{|i| i*10+9})
res = res.concat([*1..9].map{|i| i*100+99})
1.upto(13){|n|
  base = 10**n
  10.times{|i|
    10.times{|j|
      10.times{|k|
        res << base*(100*i+10*j+k)+base-1
      }
    }
  }
}
res.sort.uniq!
result = []
(res.length-100).times{|i|
  flag = true
  2.times{|j|
    if (res[i]/digit_sum(res[i]).to_f > res[i+j+1]/digit_sum(res[i+j+1]).to_f)
      flag = false
    end
  }
  if (flag)
    result << res[i]
  end
}
res = []
(result.length-20).times{|i|
  flag = true
  10.times{|j|
    if (result[i]/digit_sum(result[i]).to_f > result[i+j+1]/digit_sum(result[i+j+1]).to_f)
      flag = false
    end
  }
  if (flag)
    res << result[i]
  end
}
puts res[0..K-1]