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



Sample input:
10


Sample output:
1
2
3
4
5
6
7
8
9
19

Submission status: Accepted

Solution code:
K = int(input())
snuke = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1099, 1199, 1299, 1399, 1499, 1599, 1699, 1799, 1899, 1999, 2999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 10999, 11999, 12999, 13999, 14999, 15999, 16999, 17999, 18999, 19999, 20999, 21999, 22999, 23999, 24999, 25999, 26999, 27999, 28999, 29999, 39999, 49999, 59999, 69999, 79999, 89999, 99999, 109999, 119999, 129999, 139999, 149999, 159999, 169999, 179999, 189999, 199999, 209999, 219999, 229999, 239999, 249999, 259999, 269999, 279999, 289999, 299999, 309999, 319999, 329999, 339999, 349999, 359999, 369999, 379999, 389999, 399999, 499999, 599999, 699999, 799999, 899999, 999999, 1099999, 1199999, 1299999, 1399999, 1499999, 1599999, 1699999, 1799999, 1899999, 1999999, 2099999, 2199999, 2299999, 2399999, 2499999, 2599999, 2699999, 2799999, 2899999, 2999999, 3099999, 3199999, 3299999, 3399999, 3499999, 3599999, 3699999, 3799999, 3899999, 3999999, 4099999, 4199999, 4299999, 4399999, 4499999, 4599999, 4699999, 4799999, 4899999, 4999999, 5999999, 6999999, 7999999, 8999999, 9999999, 10999999, 11999999, 12999999, 13999999, 14999999, 15999999, 16999999, 17999999, 18999999, 19999999, 20999999, 21999999, 22999999, 23999999, 24999999, 25999999, 26999999, 27999999, 28999999, 29999999, 30999999, 31999999, 32999999, 33999999, 34999999, 35999999, 36999999, 37999999, 38999999, 39999999, 40999999, 41999999, 42999999, 43999999, 44999999, 45999999, 46999999, 47999999, 48999999, 49999999, 50999999, 51999999, 52999999, 53999999, 54999999, 55999999, 56999999, 57999999, 58999999, 59999999, 69999999, 79999999, 89999999, 99999999, 109999999, 119999999, 129999999, 139999999, 149999999, 159999999, 169999999, 179999999, 189999999, 199999999, 209999999, 219999999, 229999999, 239999999, 249999999, 259999999, 269999999, 279999999, 289999999, 299999999, 309999999, 319999999, 329999999, 339999999, 349999999, 359999999, 369999999, 379999999, 389999999, 399999999, 409999999, 419999999, 429999999, 439999999, 449999999, 459999999, 469999999, 479999999, 489999999, 499999999, 509999999, 519999999, 529999999, 539999999, 549999999, 559999999, 569999999, 579999999, 589999999, 599999999, 609999999, 619999999, 629999999, 639999999, 649999999, 659999999, 669999999, 679999999, 689999999, 699999999, 799999999, 899999999, 999999999, 1099999999, 1199999999, 1299999999, 1399999999, 1499999999, 1599999999, 1699999999, 1799999999, 1899999999, 1999999999, 2099999999, 2199999999, 2299999999, 2399999999, 2499999999, 2599999999, 2699999999, 2799999999, 2899999999, 2999999999, 3099999999, 3199999999, 3299999999, 3399999999, 3499999999, 3599999999, 3699999999, 3799999999, 3899999999, 3999999999, 4099999999, 4199999999, 4299999999, 4399999999, 4499999999, 4599999999, 4699999999, 4799999999, 4899999999, 4999999999, 5099999999, 5199999999, 5299999999, 5399999999, 5499999999, 5599999999, 5699999999, 5799999999, 5899999999, 5999999999, 6099999999, 6199999999, 6299999999, 6399999999, 6499999999, 6599999999, 6699999999, 6799999999, 6899999999, 6999999999, 7099999999, 7199999999, 7299999999, 7399999999, 7499999999, 7599999999, 7699999999, 7799999999, 7899999999, 7999999999, 8999999999, 9999999999, 10999999999, 11999999999, 12999999999, 13999999999, 14999999999, 15999999999, 16999999999, 17999999999, 18999999999, 19999999999, 20999999999, 21999999999, 22999999999, 23999999999, 24999999999, 25999999999, 26999999999, 27999999999, 28999999999, 29999999999, 30999999999, 31999999999, 32999999999, 33999999999, 34999999999, 35999999999, 36999999999, 37999999999, 38999999999, 39999999999, 40999999999, 41999999999, 42999999999, 43999999999, 44999999999, 45999999999, 46999999999, 47999999999, 48999999999, 49999999999, 50999999999, 51999999999, 52999999999, 53999999999, 54999999999, 55999999999, 56999999999, 57999999999, 58999999999, 59999999999, 60999999999, 61999999999, 62999999999, 63999999999, 64999999999, 65999999999, 66999999999, 67999999999, 68999999999, 69999999999, 70999999999, 71999999999, 72999999999, 73999999999, 74999999999, 75999999999, 76999999999, 77999999999, 78999999999, 79999999999, 80999999999, 81999999999, 82999999999, 83999999999, 84999999999, 85999999999, 86999999999, 87999999999, 88999999999, 89999999999, 99999999999, 109999999999, 119999999999, 129999999999, 139999999999, 149999999999, 159999999999, 169999999999, 179999999999, 189999999999, 199999999999, 209999999999, 219999999999, 229999999999, 239999999999, 249999999999, 259999999999, 269999999999, 279999999999, 289999999999, 299999999999, 309999999999, 319999999999, 329999999999, 339999999999, 349999999999, 359999999999, 369999999999, 379999999999, 389999999999, 399999999999, 409999999999, 419999999999, 429999999999, 439999999999, 449999999999, 459999999999, 469999999999, 479999999999, 489999999999, 499999999999, 509999999999, 519999999999, 529999999999, 539999999999, 549999999999, 559999999999, 569999999999, 579999999999, 589999999999, 599999999999, 609999999999, 619999999999, 629999999999, 639999999999, 649999999999, 659999999999, 669999999999, 679999999999, 689999999999, 699999999999, 709999999999, 719999999999, 729999999999, 739999999999, 749999999999, 759999999999, 769999999999, 779999999999, 789999999999, 799999999999, 809999999999, 819999999999, 829999999999, 839999999999, 849999999999, 859999999999, 869999999999, 879999999999, 889999999999, 899999999999, 909999999999, 919999999999, 929999999999, 939999999999, 949999999999, 959999999999, 969999999999, 979999999999, 989999999999, 999999999999, 1099999999999, 1199999999999, 1299999999999, 1399999999999, 1499999999999, 1599999999999, 1699999999999, 1799999999999, 1899999999999, 1999999999999, 2099999999999, 2199999999999, 2299999999999, 2399999999999, 2499999999999, 2599999999999, 2699999999999, 2799999999999, 2899999999999, 2999999999999, 3099999999999, 3199999999999, 3299999999999, 3399999999999, 3499999999999, 3599999999999, 3699999999999, 3799999999999, 3899999999999, 3999999999999, 4099999999999, 4199999999999, 4299999999999, 4399999999999, 4499999999999, 4599999999999, 4699999999999, 4799999999999, 4899999999999, 4999999999999, 5099999999999, 5199999999999, 5299999999999, 5399999999999, 5499999999999, 5599999999999, 5699999999999, 5799999999999, 5899999999999, 5999999999999, 6099999999999, 6199999999999, 6299999999999, 6399999999999, 6499999999999, 6599999999999, 6699999999999, 6799999999999, 6899999999999, 6999999999999, 7099999999999, 7199999999999, 7299999999999, 7399999999999, 7499999999999, 7599999999999, 7699999999999, 7799999999999, 7899999999999, 7999999999999, 8099999999999, 8199999999999, 8299999999999, 8399999999999, 8499999999999, 8599999999999, 8699999999999, 8799999999999, 8899999999999, 8999999999999, 9099999999999, 9199999999999, 9299999999999, 9399999999999, 9499999999999, 9599999999999, 9699999999999, 9799999999999, 9899999999999, 9999999999999, 10999999999999, 11999999999999, 12999999999999, 13999999999999, 14999999999999, 15999999999999, 16999999999999, 17999999999999, 18999999999999, 19999999999999, 20999999999999, 21999999999999, 22999999999999, 23999999999999, 24999999999999, 25999999999999, 26999999999999, 27999999999999, 28999999999999, 29999999999999, 30999999999999, 31999999999999, 32999999999999, 33999999999999, 34999999999999, 35999999999999, 36999999999999, 37999999999999, 38999999999999, 39999999999999, 40999999999999, 41999999999999, 42999999999999, 43999999999999, 44999999999999, 45999999999999, 46999999999999, 47999999999999, 48999999999999, 49999999999999, 50999999999999, 51999999999999, 52999999999999, 53999999999999, 54999999999999, 55999999999999, 56999999999999, 57999999999999, 58999999999999, 59999999999999, 60999999999999, 61999999999999, 62999999999999, 63999999999999, 64999999999999, 65999999999999, 66999999999999, 67999999999999, 68999999999999, 69999999999999, 70999999999999, 71999999999999, 72999999999999, 73999999999999, 74999999999999, 75999999999999, 76999999999999, 77999999999999, 78999999999999, 79999999999999, 80999999999999, 81999999999999, 82999999999999, 83999999999999, 84999999999999, 85999999999999, 86999999999999, 87999999999999, 88999999999999, 89999999999999, 90999999999999, 91999999999999, 92999999999999, 93999999999999, 94999999999999, 95999999999999, 96999999999999, 97999999999999, 98999999999999, 99999999999999, 100999999999999, 101999999999999, 102999999999999, 103999999999999, 104999999999999, 105999999999999, 106999999999999, 107999999999999, 108999999999999, 109999999999999, 119999999999999, 129999999999999, 139999999999999, 149999999999999, 159999999999999, 169999999999999, 179999999999999, 189999999999999, 199999999999999, 209999999999999, 219999999999999, 229999999999999, 239999999999999, 249999999999999, 259999999999999, 269999999999999, 279999999999999, 289999999999999, 299999999999999, 309999999999999, 319999999999999, 329999999999999, 339999999999999, 349999999999999, 359999999999999, 369999999999999, 379999999999999, 389999999999999, 399999999999999, 409999999999999, 419999999999999, 429999999999999, 439999999999999, 449999999999999, 459999999999999, 469999999999999, 479999999999999, 489999999999999, 499999999999999, 509999999999999, 519999999999999, 529999999999999, 539999999999999, 549999999999999, 559999999999999, 569999999999999, 579999999999999, 589999999999999, 599999999999999, 609999999999999, 619999999999999, 629999999999999, 639999999999999, 649999999999999, 659999999999999, 669999999999999, 679999999999999, 689999999999999, 699999999999999, 709999999999999, 719999999999999, 729999999999999, 739999999999999, 749999999999999, 759999999999999, 769999999999999, 779999999999999, 789999999999999, 799999999999999, 809999999999999, 819999999999999, 829999999999999, 839999999999999, 849999999999999, 859999999999999, 869999999999999, 879999999999999, 889999999999999, 899999999999999, 909999999999999, 919999999999999, 929999999999999, 939999999999999, 949999999999999, 959999999999999, 969999999999999, 979999999999999, 989999999999999, 999999999999999]
for k in range(K):
    print(snuke[k])

Submission status: Accepted

Solution code:
def sum_digit(n):
    n_str = str(n)
    ans = 0
    for dig in n_str:
        ans += int(dig)
    return ans

def snuke(n):
    return n / sum_digit(n)

K = int(input())

ans = 1
print(ans)
for i in range(K - 1):
    s = len(str(ans))
    x = snuke(ans)
    L = [[ans + 10 ** k, snuke(ans + 10 ** k)] for k in range(s+1)]
    L.sort(key = lambda x: x[1])
    ans = L[0][0]
    print(ans)

Submission status: Accepted

Solution code:
import sys 

K = int(input())

if K <= 0:
    sys.exit(0)

step = 1 
snuke = 1 

while K > 0:
    if step < snuke/sum(map(int, str(snuke))):
        snuke += 9 * step
        step *= 10
    else:
        print(snuke)
        snuke += step
        K -= 1

Submission status: Accepted

Solution code:
t=1
i=1
l=int(input()) 
while l:
  if t<i/sum(map(int,list(str(i)))):
    i+=9*t
    t*=10
  else:
    print(i)
    i+=t
    l-=1

Submission status: Accepted

Solution code:
import math
# import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(input())
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)

	while m >= 1:
		s_m = s(m)
		s_mplus1 = s(m + 1)

		if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8 and s_n - s_m != -17)) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break


		m -= 10 ** int(log_n // 1.25)


# 適当な大きいスヌケ数
current_sunuke = 999999999999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

# start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))

Submission status: Accepted

Solution code:
import math
# import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(input())
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)
	# m = n - 1

	while m >= 1:
		s_m = s(m)
		s_mplus1 = s(m + 1)

		# if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8)) and m > 9:
		if (s_m < s_mplus1) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break
		# else:
		# 	log_m = int(math.log(m,10))
		# 	if (m + 1) / (10 ** (log_m - 1)) == 19:

		# 		print ("skip: " + str(m) + " to " + str(10 ** log_m - 1))

		# 		m = 10 ** log_m - 1
		# 		s_mplus1 = s(m+1)
		# 		continue

		m -= 10 ** int(log_n // 1.25)


# 適当な大きいスヌケ数
current_sunuke = 999999999999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

# start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))

# sunukes=[]

# n = current_sunuke - 1

# while(n >= 1):
# 	s_n = n / s(n)
# 	if s_n <= current_sunuke_n:
# 		#sunukes.insert(0,n)
# 		sunukes.append(n)
# 		current_sunuke = n
# 		current_sunuke_n = s_n
# 	n -= 1

# for n in sunukes:
# 	print (n)

Submission status: Accepted

Solution code:
l=int(input())

def f(n):
	return n/sum(list(map(int,list(str(n)))))

a=[]
for i in range(1,16):
	if i<=3:
		for j in range(1,10):
			a.append((j+1)*(10**(i-1))-1)
	elif i<=12:
		for j in range(1,10):
			b=[j*(10**(i-1))+(k+1)*(10**(i-2))-1 for k in range(10)]
			for k in range(9)[::-1]:
				if f(b[k])>f(b[k+1]):
					b.pop(k)
			a+=b
	else:
		for j in range(1,10):
			b=[j*(10**(i-1))+(k+1)*(10**(i-3))-1 for k in range(100)]
			for k in range(99)[::-1]:
				if f(b[k])>f(b[k+1]):
					b.pop(k)
			a+=b

for i in range(l):
	print(a[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def S(n):
    s = 0
    while n != 0:
        s += n % 10
        n //= 10
    return s

# @mt
def slv(K):
    ans = [(i, i/S(i)) for i in range(1, 10)]
    for i in range(16):
        a = i
        if a > 4:
            a = 4
        for j in range(1, 10**a):
            b = (10**(i-a+1))*j + (10**(i-a+1)-1)
            if b < 10**(i-1):
                continue
            s = S(b)
            
            while ans[-1][1] > b/s or ans[-1][0] == b:
                (ans.pop())
            ans.append((b, b/s))
            # print(ans[-1])
    # error_print(len(ans))
    # for r in ans:
    #     error_print(r)
    error_print(len(ans))
    
    return '\n'.join(map(str, map(lambda x: x[0], ans[:K])))


def main():
    K = read_int()
    print(slv(K))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
k = int(input())


def snuke(n):
    s = 0
    for _ in str(n):
        s += int(_)
    return n / s


n = 1
d = 0
for _ in range(k):
    print(n)
    if snuke(n + 10**d) > snuke(n + 10**(d + 1)):
        d += 1
    n += 10**d

Submission status: Accepted

Solution code:
k = int(input())
n = 1
dif = 1
cnt = 0

while cnt!=k:
  sn = 0
  for ele in str(n):
    sn+=int(ele)

  m = n+dif
  sm = 0
  for ele in str(m):
    sm+=int(ele)
  if (n/sn) <= (m/sm):
    print(n)
    cnt+=1
    n+=dif
  else:
    n-=dif
    dif*=10
    n+=dif

Submission status: Accepted

Solution code:
K = int(input())

def snk(n):
   s = 0
   for i in str(n):
       s += int(i)
   return n / s

x = 1
y = 1
for _ in range(K):
    print(x)
    if snk(x + y) > snk(x + y * 10):
        y *= 10
    x += y

Submission status: Accepted

Solution code:
def f(x):
    return x / sum(map(int, str(x)))

n = int(input())

x = 1
y = 1

for i in range(n):
    print(x)
    if f(x + y) > f(x + y * 10):
        y *= 10
    x += y

Submission status: Accepted

Solution code:
K = int(input())

a = 1
b = 0

def snk(n):
    s = 0
    for i in str(n):
        s += int(i)
    return(n/s)
    
count = 0
while True:
    print(a)
    count += 1
    if snk(a + 10 ** b) > snk(a + 10 ** (b + 1)):
        b += 1
    a += 10 ** b
    if count == K:
        break

Submission status: Accepted

Solution code:
k = int(input())

a = 1
b = 1

def snk(n):
    s = 0
    for i in str(n):
        s += int(i)
    return n / s

for _ in range(k):
    print(a)
    if snk(a + 10 ** (b -1)) > snk(a + 10 ** b):
        b += 1
    a += 10 ** (b-1)

Submission status: Accepted

Solution code:
K = int(raw_input())
x = 1
d = 1
for i in range(K):
  print x
  s1 = sum(map(int,str(x+d)))
  s10 = sum(map(int,str(x+d*10)))
  if (x+d)*s10 >= (x+d*10)*s1:
    d *= 10
  x += d

Submission status: Accepted

Solution code:
def f(num):
    s = 0
    for char in str(num):
        s += int(char)

    return num / s

K = int(input())
num = 1
power = 1
for _ in range(K):
    print(num)
    if f(num + 10 ** (power - 1)) > f(num + 10 ** power):
        power += 1
    num += 10 ** (power - 1)

Submission status: Accepted

Solution code:
#abc101d

def f(n):
 s=0
 for t in str(n):
  s+=int(t)
 return 1.0*int(n)/s

k=int(raw_input())
x,y=1,1
for i in xrange(k):
 print x
 if f(x+10**(y-1))>f(x+10**(y)):
  y+=1
 x+=10**(y-1)

Submission status: Accepted

Solution code:
K = int(input())

def S(n):
    return sum(int(c) for c in str(n))

n9 = 0	# the number of 9s

count = 0
upper = 1
while count < K:
    n = int(str(upper) + ('9' * n9))
    if n <= S(n) * (10 ** n9):
        print(n)
        count += 1
        upper += 1
    else:
        n9 += 1
        upper //= 10

Submission status: Accepted

Solution code:
import math

def next_sunuke(N):
    D = math.ceil(math.log(N,10) + 1)
    z = str(N)
    zx = [int(z[:1]) for z in z]
    Z = N / sum(zx)
    ret_val = N
#    print(Z)
    ret_vals = [ret_val]
    for d in range(0, D):
        x = ( (10 ** (d + 1)) * math.floor((N / (10 ** (d+1))) + 1 ) ) - 1
#        print(x)
        w = str(x)
        sx = [int(w[:1]) for w in w]
        y = x / sum(sx)
#        print(x,w,sx,sum(sx),y)
        if y == Z:
            Z = y
            ret_vals.append(x)
        elif y < Z:
            Z = y
            ret_vals = []
            ret_vals.append(x)
        #print(min(ret_vals))

#    print(ret_vals)
    return min(ret_vals)

K = int(input())
n = 1
for i in range(1,K+1):
    print(next_sunuke(n))
    n = next_sunuke(n) + 1

Submission status: Accepted

Solution code:
LEN = 0

SNK = [1,2,3,4,5,6,7,8,9]
#SNK.append("SUNUKE!:"+str(1))
LEN +=1

for i in range(1,10): SNK.append(i*10+9)
#SNK.append("SUNUKE!:"+str(2))
LEN +=1

#for i in range(1,10): SNK.append(i*100+99)
#SNK.append("SUNUKE!:"+str(3))
LEN +=1

for loop in range(2):
    SNK_sub = list(range(pow(10,loop),pow(10,loop+1)))
    SNK += list(map(lambda x:(x*pow(10,LEN-1))+(pow(10,LEN-1)-1),SNK_sub))
    LEN += len(str(max(SNK_sub)))-1
    for d in SNK_sub: #loop=0のとき，d=1-9
        SNK += [(i*pow(10,LEN-1))+(pow(10,LEN-1)-1) for i in range(10,10*(d+1))]
        SNK += list(map(lambda x:(x*pow(10,LEN))+(pow(10,LEN)-1),SNK_sub[SNK_sub.index(d)+1:]))
        #SNK.append("SUNUKE!:"+str(LEN+3))
        LEN += 1+loop
        if LEN>20:break

print("\n".join(str(i) for i in SNK[:int(input())]))

Submission status: Accepted

Solution code:
from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(input())
 
def f(n):
    ds = range(int(log(n+1, 10))+1)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:n / sum(map(int, str(n))))
 
snukes = chain(range(1, 9), accumulate(repeat(9), lambda x,_:f(x+1)))
 
for x in islice(snukes, k):
    print(x)

Submission status: Accepted

Solution code:
from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(input())
 
def f(n):
    ds = range(int(log(n+1, 10))+2)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:(n / sum(map(int, str(n))), n))
 
snukes = chain(range(1, 9), accumulate(repeat(9), lambda x,_:f(x+1)))

for x in islice(snukes, k):
    print(x)

Submission status: Accepted

Solution code:
K=input()

def sunuke(m):
	a=sum( map(int,list(str(m))) )
	return float(m)/a

def f(n):
	res=n
	snk=sunuke(n)

	for keta in range(1,15):
		val=n%10
		n/=10
		for i in range(val,10):
			t=n*(10**keta)+i*(10**(keta-1))+(10**(keta-1))-1
			if sunuke(t)<snk:
				snk=sunuke(t)
				res=t
	return res


N=1
for i in range(K):
	N=f(N)
	print N
	N+=1

Submission status: Accepted

Solution code:
def s(n):
	return sum([ord(x)-ord('0') for x in str(n)])

def r(n):
	return n/s(n)

def f(n):
	d = 10
	m = n
	while d <= n*10:
		n //= d
		n *= d
		n += d-1
		d *= 10
		if(r(n) < r(m)):
			m = n
	return m

n = 1
for _ in range(int(input())):
	print(n)
	n = f(n+1)

Submission status: Accepted

Solution code:
def f(n):
    return n/sum(map(int,list(str(n))))
a=1
b=0
for i in range(int(input())):
    print(a)
    if f(a+10**b) > f(a+10**(b+1)):
        b+=1
    a+=10**b

Submission status: Accepted

Solution code:
def f(n):
    s, a = 0, n
    while n > 0:
        s += n % 10
        n //= 10

    return a / s


def main():
    snuke = []
    base = 1

    for i in range(15):
        for j in range(1, 140):
            snuke.append(base*(j+1)-1)
        base *= 10

    snuke.sort()
    snuke.append(0)

    snuke2 = []
    for i in range(len(snuke)-1):
        if snuke[i] != snuke[i+1]:
            snuke2.append(snuke[i])

    k, idx, t = int(input()), 0, 0
    while t < k:
        for i in range(idx+1, len(snuke2)):
            if f(snuke2[idx]) > f(snuke2[i]):
                idx += 1
                break
        else:
            print(snuke2[idx])
            t += 1
            idx += 1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
K = int(input())
i=1
addNum = 1
ans = []
while(K!=0):
        print(i)
        K-=1
        S1 = 0
        S2 = 0
        for j in list(str(i+addNum)):
                S1 += int(j)
        for j in list(str(i+addNum+addNum)):
                S2 += int(j)
        if (i+addNum)/S1 > (i+addNum+addNum)/S2:
                addNum *= 10
        i += addNum

Submission status: Accepted

Solution code:
k = int(input())
def f(n):
	num,ans = n/sum([int(i) for i in str(n)]),n
	for i in range(len(str(n))+1):
		x = (10**(i+1))*(n//(10**(i+1))+1)-1
		y = x/sum([int(j) for j in str(x)])
		if num>y: ans,num = x,y
	return ans
n = 0
for _ in range(k):
	n = f(n+1)
	print(n)

Submission status: Accepted

Solution code:
# coding : utf-8

K = int(input())

Sunuke = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def ns(n):
    return n / sum(map(int, list((str(n)))))

# 10以上は、ある位に注目したとき、その下の位全てが9の場合すぬけ数の候補となる
if K <= len(Sunuke):
    for i in range(K):
        print(Sunuke[i])

else:
    # 見つけなければいけない残りのすぬけ数
    resi = K - len(Sunuke)
    # 注目している位
    digit = 0
    snk = 9

    while resi > 0:
        nxt1 = snk + 10**digit
        nxt2 = snk + 10**(digit+1)

        # 注目の位に対して1つ上の位により小さな値があったときは、注目の位を１つ上げる
        if ns(nxt1) > ns(nxt2):
            digit +=1
            snk = nxt2
            Sunuke.append(snk)
            resi -= 1
        else:
            snk = nxt1
            Sunuke.append(snk)
            resi -= 1


for i in range(K):
    print(Sunuke[i])

Submission status: Accepted

Solution code:
MAX = 10**15

def find_next_n(n):
    cand = []
    n_str = str(n)
    n_list = list(n_str)
    for i in range(1,len(str(n))+1):
        n_list[-i] = '9'
        cand.append(int("".join(n_list)))
    cand_result = [num/snuke(num) for num in cand]
    min_idx = cand_result.index(min(cand_result))

    return cand[min_idx]
    
    
def snuke(num):
    ans = 0
    while num//10 != 0:
        ans += num%10
        num = num//10
    return ans + num

def main():
    K = int(input())
    if K<10:
        for i in range(1,K+1):
            print(i)
    else:
        n = 10
        for i in range(1,n):
            print(i)
        for i in range(10,K+1):
            ans = find_next_n(n)
            print(ans)
            n = ans+1
            
            if n>MAX:
                break
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def d_snuke_numbers(K):
    import math

    def ns(n):  # n/S(n)の計算
        return n / sum(map(int, list(str(n))))

    def f(n):  # n<=xの中で ns(x) を最小にするような最小の値xを求める
        digit = len(str(n))
        # n自身も候補の1つである
        min_ns = ns(n)
        ret = n
        for d in range(digit + 1):
            x = (10**(d+1)) * math.floor(n / (10**(d+1)) + 1) - 1
            s = ns(x)
            if min_ns > s:
                min_ns = s
                ret = x
        return ret

    n = 0
    candidate = []
    for _ in range(K):
        n = f(n + 1)
        candidate.append(n)
    ans = '\n'.join(map(str, candidate))
    return ans

K = int(input())
print(d_snuke_numbers(K))

Submission status: Accepted

Solution code:
def s(n):
    ret=0    
    for i in range(15):
        ret+=(n%10**(i+1))//10**i
    return ret

k=int(input())
ans=set()
for i in reversed(range(14)):
    m=float('inf')
    for j in reversed(range(1,1000)):
        n=int(str(j)+'9'*i)
        if n/s(n)<=m :
            ans.add(n)
            m=n/s(n)
ans=sorted(list(ans))
for a in ans[:k]:
    print(a)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)

Submission status: Accepted

Solution code:
K = int(input())

def S(n):
    return sum(map(int, list(str(n))))

def norm(n):
    return n/S(n)

snk = 1
order = 0
for i in range(K):
    print(snk)
    nxt1 = snk + 10 ** order
    nxt2 = snk + 10 ** (order + 1)
    if norm(nxt2) < norm(nxt1):
        order += 1
        snk = nxt2
    else:
        snk = nxt1

Submission status: Accepted

Solution code:
def nsn(n):
    s = 0
    nn = n
    while nn > 0:
        s += nn % 10
        nn = int(nn / 10)
    return n / s

def big(a):
    r = 1
    while a > 0:
        r *= 10
        a = int(a / 10)
    return r

def clear(a, d):
    aa = a
    asa = nsn(a)
    b = True
    ba = big(a)
    while aa < ba:
        aa += d
        if nsn(aa) < asa:
            b = False
            break
    return b

K = int(input())
T = [1]
a = 1
d = 1
while len(T) < K:
    n = 1
    while 1:
        an = a + n * d
        if clear(an, d):
            T.append(an)
            a = an
            d = n * d
            break
        n += 1
for x in T:
    print(x)

Submission status: Accepted

Solution code:
from math import log, floor
from itertools import islice

k = int(input())

def s(n):
    return n / sum(map(int, str(n)))

def f(n):
    ds = range(int(log(n+1, 10))+2)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=s)

def g():
    for n in range(1, 10):
        yield n
    while True:
        n = f(n+1)
        yield n

for x in islice(g(), k):
    print(x)

Submission status: Accepted

Solution code:
K = int(input())

def calc(n):
    return sum(int(c) for c in str(n))

def check(n):
    for i in range(1, len(str(n))):
        p = 10**i
        m = (n // p + 1) * p - 1
        if n / calc(n) > m / calc(m):
            return False
    return True

def getlist():
    n, prev_n, d = 1, 0, 1
    while 1:
        if check(n):
            yield n
            d = n - prev_n
            prev_n = n
        n += d

from itertools import islice

for n in islice(getlist(), K):
    print(n)

Submission status: Accepted

Solution code:
K = int(input())
num = 1
pls = 1
coun = 0

while num <= 1000000000000000 and coun < K:
    while (num/sum(list(map(int, list(str(num)))))) <= ((num+pls)/sum(list(map(int, list(str(num+pls)))))) and coun < K:
        print(num)
        coun = coun + 1
        num = num + pls
    num = num - pls
    pls = pls * 10
    num = num + pls

Submission status: Accepted

Solution code:
k = int(input())
n=0
a=1
b=0
if a==1 and n<9:
    while n<9 and b<k:
        n+=1
        print(n)
        b+=1
    a+=1
if a==2:
    while n<90 and b<k:
        n+=10
        print(n)
        b+=1
    a+=1
while b<k:
    n+=10**(a-1)
    print(n)
    b+=1
    if (n>((a-1)*10**a-10**(a-1)) and a<12) or (n>((a-2)*10**a-10**(a-1)) and a>=12):
        a+=1

Submission status: Accepted

Solution code:
K = int(input())

def calc(n):
    m = 0
    while n:
        n, d = divmod(n, 10)
        m += d
    return m

def find(xs, i):
    ri, rv = None, 10**20
    for j in range(i, len(xs)):
        if xs[j] < rv:
            ri = j
            rv = xs[j]
    return ri, rv

c = 0
i = 1
prev = 0
d = 1
while 1:
    n = i
    r = 0
    k = 0
    vs = []
    while 1:
        n, m = divmod(n, 10)
        r += m
        if n == 0:
            break
        k += 1
        vs.append((n + 1) * 10**k - 1)
    if (not vs) or i / r <= min(v / calc(v) for v in vs):
        print(i)
        d = max(d, i - prev)
        prev = i
        c += 1
        if c >= K:
            break
    i += d

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
from operator import itemgetter

k =int(input())
nmax=0
s = []
for i in range(1,200):
    for j in range(14):
        p = i
        for ii in range(j):
            p=p*10+9
        q = i // 100 + (i // 10) % 10 + i % 10 + 9*j
        r = p / q

        s.append((p,q,r))

s= sorted( s, key=itemgetter(2) )
#print(s)
num=0
for a in s :
    if a[0] > nmax:
        nmax = a[0]
        print(nmax)
        num += 1
        if num >= k :
            break