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 Go (1.6) (judge verdict: Wrong Answer)

// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Jan 24 16:20:46 2019
//
package main

import (
	"fmt"
	"sort"
	"strconv"
)

func digitSum(n int) int {
	s := strconv.Itoa(n)

	sum := 0
	for i := range s {
		sum += int(s[i] - '0')
	}
	return sum
}

func unique(slice []int) []int {
	ret := []int{}
	for _, s := range slice {
		hasSame := false
		for _, r := range ret {
			if r == s {
				hasSame = true
			}
		}
		if !hasSame {
			ret = append(ret, s)
		}
	}

	return ret
}

func pow10(n int) int {
	if n == 0 {
		return 1
	}
	return 10 * pow10(n-1)
}

func main() {
	var K int
	fmt.Scan(&K)
	candidates := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}

	for i := 1; i <= 15; i++ {
		for j := 1; j <= 150; j++ {
			n := pow10(i)
			if j*n+n-1 <= 1e15 {
				candidates = append(candidates, j*n+n-1)
			}
		}
	}

	candidates = unique(candidates)
	sort.Ints(candidates)

	anss := make([]int, 0)
	for i, n := range candidates {
		for j := i + 1; j < len(candidates); j++ {
			m := candidates[j]
			if digitSum(m)*n > digitSum(n)*m {
				continue
			}
		}
		anss = append(anss, n)
	}

	for i := 0; i < K; i++ {
		fmt.Println(anss[i])
	}
}