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

Solution code:
import math 
def S(N):
    s = 0
    n = N
    while n != 0:
        s += n % 10
        n /= 10
        n = math.floor(n)
    return s

def t(N):
    # print("N", N)
    # print("SN", S(N))
    return N / S(N)

def getNine(n, k):
    hdigit = n % pow(10, k)
    nined = n + (pow(10, k) - 1) - hdigit
    return nined

def isSnuke(n):
    if n == 1:
        return True

    # first = n % 10
    # firstIsNine = n + 9 - first
    # 
    # second = int(n / 10) % 10
    # firstSecondIsNine = firstIsNine + 90 - second * 10
    # 
    # third = int(n / 100) % 10
    # firstSecondThirdIsNine = firstSecondIsNine + 900 - third * 100
    
    m = 1
    h = 1
    while m <= n:
        m *= 10
        h += 1
    m -= 1

    for k in range(1, h):
        nined1 = getNine(n, k)
        nined2 = getNine(n, k + 1)
        checkers = range(nined1, nined2, pow(10, k))
        # print(checkers)
        for c in checkers:
            if t(n) > t(c):
                return False
    return True
    
#     # print(firstIsNine)
#     if t(n) > t(firstIsNine):
#         return False
#     nVal = n / S(n)
#     
#     mVal = m / S(m)
#     return (nVal <= mVal)
# 
def listSnuke(k):
    n = 0
    number = 0
    while number < k:
        n += 1
        # print('nined n =', getNine(n, 2), n)
        if isSnuke(n):
            print(n)
            number += 1

listSnuke(int(input()))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

k = int(input())

targets = []
for i in range(1, 10**4*8):
    targets.append(i/sum(list(map(int, list(str(i))))))

min_list = [10**10]
for target in reversed(targets):
    min_list.insert(0, min([min_list[0], target]))

i = 0
count = 1
while count <= k:
    if targets[i] <= min_list[i]:
        print(i+1)
        count += 1
    i += 1

Submission status: Time Limit Exceeded

Solution code:

import math
def sn(i):
    tmp = i % 10
    sn = tmp
    tmp1 = math.floor(i/10)
    while tmp1 > 0:
        tmp = tmp1 % 10
        sn += tmp
        tmp1 = math.floor(tmp1/10)
    return sn

def hantei(i):

    while i > 9:
        tmp = i % 10
        if tmp != 9:
            return False
        i = math.floor(i/10)
    return True

k = int(input())
i = 0
cnt = 1
while i != k:
    if math.floor(cnt / 10) == 0:
        print(cnt)
        i += 1
    elif hantei(cnt):
        print(cnt)
        i += 1
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
import math
k = int(input())

def get_s(n):
    s_n = 0
    for e_str in str(n):
        s_n += int(e_str)
    return s_n

n = 1
ans = set()
while(True):
    s_n = get_s(n)
    left = n / s_n
    is_not_sunuke = False
    for m in range(n + 1, n + 1 + 100):
        s_m = get_s(m)
        right = m / s_m
        if left > right:
            is_not_sunuke = True
            break
    if not is_not_sunuke:
        ans.add(n)
    n += 1
    if n > 100000000000000:
        break
    if len(ans) >= k:
        break

ans_list = list(ans)
ans_list.sort()
for i in range(0, k):
    print(ans_list[i])

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def sunuke(N):
    res = 0
    for n in str(N):
        res += int(n)
    return res



i, n, n_len= 0, 0, 1
while i < K:
    n += 1
    if n / sunuke(n) <= ((n+1)/ sunuke(n+1)) and len(str(n)) < n_len:
        if str(n)[-1] == "9":
            if n / sunuke(n) <= ((n+10)/ sunuke(n+10)):
                print(n)
                i += 1
                n_len += 1
            
        else:
            print(n)
            i += 1

Submission status: Time Limit Exceeded

Solution code:
import math
hahaha = int(input())
t = 100000
min = 1e16
keta = 15
nine = "999999999999999999999"
ans = []
for i in range(keta-5):
    i = keta - i
    for j in range(1,t-9):
        j = t - j
        st = str(j)
        hoge = st+nine
        target = int(hoge[0:i])
        sum = 0
        ltarget = list(str(target))
        for a in ltarget:
            sum += int(a)
        num = target / sum
        if min >= num:
            min = num
            # print(target,num)
            ans.append(target)
for i in range(1,t):
    i = t - i
    li = list(str(i))
    sum = 0
    for a in li:
        sum += int(a)
    num = i / sum
    if min >= num:
        min = num
        # print(i,num)
        ans.append(i)
ans.sort()
for i in range(hahaha):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

snuke = [1]

cnt = 0
old_candidate = 1
for i in range(3, K**15 + 1):
    s_n = 0
    t = i
    while t > 0:
        s_n += t%10
        t //= 10
    candidate = i / s_n
    if candidate >= old_candidate:
        snuke.append(i-1)
        old_candidate = candidate
        cnt += 1
    if cnt == K - 1:
        break

for val in snuke:
    print(val)

Submission status: Time Limit Exceeded

Solution code:
def func(x):
    ret = 0
    while x > 0:
        ret += x % 10
        x //= 10
    return ret

def getSn(x):
    return x / func(x)

if __name__ == '__main__':
    k = int(input())
    sn = [1]
    i = 2
    while len(sn) < k + 1:
        buf = getSn(i)
        while getSn(sn[-1]) > buf:
            sn.pop()
            if len(sn) == 0:
                break
        sn += [i]
        i += 1
        #print(sn)
    for i in range(k):
        print(sn[i])

Submission status: Time Limit Exceeded

Solution code:
import math
k = int(input())

def get_s(n):
    s_n = 0
    for e_str in str(n):
        s_n += int(e_str)
    return s_n

n = 1
ans = set()
while(True):
    s_n = get_s(n)
    left = n / s_n
    is_not_sunuke = False
    for m in range(n + 1, n + 1 + 5):
        s_m = get_s(m)
        right = m / s_m
        if left > right:
            is_not_sunuke = True
            break
    for i in range(1, len(str(n))):
        m = str(n)[:-i]
        add_num = 1
        for _ in range(0, i):
            m += '0'
            add_num *= 10
        m = int(m)
        m += add_num - 1
        s_m = get_s(m)
        right = m / s_m
        if left > right:
            is_not_sunuke = True
            break

    if not is_not_sunuke:
        ans.add(n)
    n += 1
    if len(ans) >= k:
        break

ans_list = list(ans)
ans_list.sort()
for i in range(0, k):
    print(ans_list[i])

Submission status: Time Limit Exceeded

Solution code:

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

if __name__ == "__main__":
    K = int(input())
    n = 0
    Sn = [0] # 添字0は便宜上埋めておく
    RANGE_ = 100
    while n != RANGE_:
        n += 1
        Sn.append(eval_sn(n))

    while K != 0:
        n += 1
        #
        Sn.append(eval_sn(n))
        check = 0
        for j in range(RANGE_):
            if (Sn[n-RANGE_] <= Sn[n-j]):
                check += 1
                continue
            else:
                break
        if check == RANGE_:
            K -= 1
            print(n-RANGE_)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

curmin = 1
cnt = 0
i = 1

while cnt <= (K - 1) :
    cand_i = i / sum(list(map(int, list(str(i)))))
    
    str_len = len(list(str(i)))
    # print("DBG : ", str_len)
    if str_len == 1 :
        if cand_i <= len(list(str(i))) :
            print(i)
            cnt += 1
    else :
        if cand_i < len(list(str(i))) :
            print(i)
            cnt += 1
        
    i += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

import numpy as np

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

count_k = 0
for i in range(1,10**15+1):
    d = len(str(i))
    loop_list = np.arange(i,10**(d-1)) * (10 ** (d-1)) + 9
    for j in range(i,10**d):
        if sunuke(i) > sunuke(j):
            break
    else:
        count_k += 1
        print(i)
        if count_k == k:
            break

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

import numpy as np

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

count_k = 0
for i in range(1,10**15+1):
    d = len(str(i))
    loop_list = np.arange(i,10**(d-1)) * 10 + 9
    for j in range(i,10**d):
        if sunuke(i) > sunuke(j):
            break
    else:
        count_k += 1
        print(i)
        if count_k == k:
            break

Submission status: Time Limit Exceeded

Solution code:
import math 
def S(N):
    s = 0
    n = N
    while n != 0:
        s += n % 10
        n /= 10
        n = math.floor(n)
    return s

def t(N):
    # print("N", N)
    # print("SN", S(N))
    return N / S(N)

def isSnuke(n):
    if n == 1:
        return True

    first = n % 10
    firstIsNine = n + 9 - first

    m = 1
    while m <= n:
        m *= 10
    m -= 1
    
    checkers = range(firstIsNine, m, 10)
    # print(checkers)
    for c in checkers:
        if t(n) > t(c):
            return False
    return True
    
#     # print(firstIsNine)
#     if t(n) > t(firstIsNine):
#         return False
#     nVal = n / S(n)
#     
#     mVal = m / S(m)
#     return (nVal <= mVal)
# 
def listSnuke(k):
    n = 0
    number = 0
    while number < k:
        n += 1
        if isSnuke(n):
            print(n)
            number += 1

listSnuke(int(input()))

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def sunuke(N):
    res = 0
    for n in str(N):
        res += int(n)
    return res



i, n = 0, 0
while i < K:
    n += 1
    
    if n / sunuke(n) <= ((n+1)/ sunuke(n+1)):
        check = 0
        for add in range(1, 11):
            if n / sunuke(n) <= ((n+add)/ sunuke(n+add)):
                check += 1
            if check == 11:
                print(n)
                i += 1

Submission status: Time Limit Exceeded

Solution code:
def sumd(n):
    res=0
    while n>0:
        res+=(n%10)
        n=int(n/10)
    return res

k=int(input())

cnt=0
n=1
m=n+1
x=list()
flag=1

while cnt<k:
    while m<n/2+n:
        #print("n="+str(n))
        if (n/sumd(n))<=(m/sumd(m)):
            #print("  m="+str(m))
            m=m+1
            flag=1
        else:
            flag=0
            break
    #print("flag="+str(flag))
    if flag==1:
        cnt+=1
        x.append(n)
    n+=1
    m=n+1
        
for i in x:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
def sumd(n):
    res=0
    while n>0:
        res+=(n%10)
        n=int(n/10)
    return res

k=int(input())

cnt=0
n=1
m=n+1
x=list()
flag=1

while cnt<k:
    while m<2*n:
        #print("n="+str(n))
        if (n/sumd(n))<=(m/sumd(m)):
            #print("  m="+str(m))
            m=m+1
            flag=1
        else:
            flag=0
            break
    #print("flag="+str(flag))
    if flag==1:
        cnt+=1
        x.append(n)
    n+=1
    m=n+1
        
for i in x:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
def sumd(n):
    res=0
    while n>0:
        res+=(n%10)
        n=int(n/10)
    return res

k=int(input())

cnt=0
n=1
m=n+1
x=list()
flag=1

while cnt<k:
    while m<n*n:
        #print("n="+str(n))
        if (n/sumd(n))<=(m/sumd(m)):
            #print("  m="+str(m))
            m=m+1
            flag=1
        else:
            flag=0
            break
    #print("flag="+str(flag))
    if flag==1:
        cnt+=1
        x.append(n)
    n+=1
    m=n+1
        
for i in x:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
"""
すぬけ
"""
import math
def sn(i):
    tmp = i % 10
    sn = tmp
    tmp1 = math.floor(i/10)
    while tmp1 > 0:
        tmp = tmp1 % 10
        sn += tmp
        tmp1 = math.floor(tmp1/10)
    return sn

def hantei(i):

    while i > 9:
        tmp = i % 10
        if tmp != 9:
            return False
        i = math.floor(i/10)
    return True

list  = []
k = int(input())
max = 0
i = 0
cnt = 1
while i != k:
    """
一桁なら全部
n桁ならn-1桁全部9の数が下から採用
    """
    if math.floor(cnt / 10) == 0:
        list.append(cnt)
        i += 1
    elif hantei(cnt):
        list.append(cnt)
        i += 1
    cnt += 1


for i in list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

idx = 1 
while K > 0:
    n = idx 
    sn = sum([int(x) for x in str(idx)])
    if (n/sn) < 2:
        print(n)
        K -= 1
    idx += 1

Submission status: Time Limit Exceeded

Solution code:
K = input()
h = int(K)
i = 0

def all_nine(i):
    if i < 10: return True
    x = str(i)[1:]
    #print(x)
    for y in x:
        if y != '9':
            return False
    # 二文字目以降すべて9
    return True

while h > 0:
    i += 1
    s = 0
    #for j in str(i):
    #    s += int(j)
    if all_nine(i):
        print(i)
        h -= 1

Submission status: Time Limit Exceeded

Solution code:
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

lst = [0]
ans = []
k = int(input())
tmp = 0
cnt = 0
i = 1
while cnt != k:
    if str(i)[1:] == '9'*(len(str(i))-1) or i < 10:
        print(i)
        cnt += 1
    i += 1

Submission status: Time Limit Exceeded

Solution code:
K = input()
h = int(K)
i = 0

def all_nine(i):
    if i < 10: return True
    x = str(i)[1:]
    #print(x)
    for y in x:
        if y != '9':
            return False
    # 二文字目以降すべて9
    return True

while h > 0:
    i += 1
    s = 0
    for j in str(i):
        s += int(j)
    #print(i, i/s)
    if all_nine(i):
        print(i)
        h -= 1

Submission status: Time Limit Exceeded

Solution code:

k = int(input())

def get_s(n):
    s_n = 0
    for e_str in str(n):
        s_n += int(e_str)
    return s_n

n = 1
ans = set()
while(True):
    s_n = get_s(n)
    left = n / s_n
    is_not_sunuke = False
    for m in range(n + 1, n + 1 + 100):
        s_m = get_s(m)
        right = m / s_m
        if left > right:
            is_not_sunuke = True
            break
    if not is_not_sunuke:
        ans.add(n)
    n += 1
    if len(ans) >= k:
        break

ans_list = list(ans)
ans_list.sort()
for i in range(0, k):
    print(ans_list[i])

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

count_k = 0
for i in range(1,10**15+1):
    d = len(str(i))
    for j in range(i,10**d+1):
        if sunuke(i) > sunuke(j):
            break
    else:
        count_k += 1
        print(i)
        if count_k == k:
            break

Submission status: Time Limit Exceeded

Solution code:
k = input()
num = 1
ans = 0
while ans < int(k):
    if (num/sum(list(map(int,str(num))))) > ((num+1)/sum(list(map(int,str(num+1))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+2)/sum(list(map(int,str(num+2))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+3)/sum(list(map(int,str(num+3))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+5)/sum(list(map(int,str(num+5))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+8)/sum(list(map(int,str(num+8))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+9)/sum(list(map(int,str(num+9))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+10)/sum(list(map(int,str(num+10))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+11)/sum(list(map(int,str(num+11))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+99)/sum(list(map(int,str(num+99))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+100)/sum(list(map(int,str(num+100))))):
        pass
        num += 1
    elif (num/sum(list(map(int,str(num))))) > ((num+101)/sum(list(map(int,str(num+101))))):
        pass
        num += 1
    else:
        print(num)
        num += 1
        ans += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(raw_input())
number = 0
i = 0
while number < K:
  i += 1
  if sum(map(int, str(i))) == (number + 1):
    print(i)
    number += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(raw_input())
number = 0
i = 1
while number < K:
  if sum(map(int, str(i))) == (number + 1):
    print(i)
    number += 1

Submission status: Time Limit Exceeded

Solution code:
K = input()
h = int(K)
i = 0
while h > 0:
    i += 1
    s = 0
    for j in str(i):
        s += int(j)
    if(int(i/s)) == 1:
        print(i)
        h -= 1

Submission status: Time Limit Exceeded

Solution code:
q="D"
if q=="A":
	S=input()
	print(sum((i=="+")-(i=="-")for i in S))
if q=="B":
	a=int(input())
	b=sum(int(i) for i in str(a))
	print("Yes" if a%b==0 else "No")
if q=="C":
	N,K=map(int,input().split())
	A=[int(i) for i in input().split()]
	minindex=A.index(min(A))
	cl=minindex
	cr=N-minindex-1
	func=lambda a,b:int(a/b) if a%b==0 else int(a/b+1)
	print(func(cl,K-1)+func(cr,K-1))
if q=="D":
	K=int(input())
	S=lambda x:sum(int(i) for i in str(x))
	#for i in range(1,110):
	r=0
	for i in range(1,10**15):
		a=i
		b=int(K/10)*10+9
		if a/S(a)<=b/S(b):
			print(a)
			r+=1
			if r==K:
				break

Submission status: Time Limit Exceeded

Solution code:
def S(n):
    n = str(n)
    sn = 0
    for i in range(len(n)):
        sn += int(n[i])
    return sn

K = int(input())
max_value = 0
count = 0
for i in range(1, 10**15+2):
    sn = S(i)
    if max_value < sn:
        print(i)
        max_value = sn
        count += 1
    if count == K:
        break

Submission status: Time Limit Exceeded

Solution code:
def d(s):
    return sum([int(c) for c in str(s)])
  
k=int(input())

c=1
i=1
while True:
    if d(i)==c:
        print(i)
        if c==k:
            break
        c+=1
        
    i+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
sn_list = []
for n in range(1,10**15):
    sn = 0
    for i in str(n):
        sn += int(i)
    sn_list.append(n//sn)
sunuke_list = []
counter = 1
while(not(sn_list == [])):
    if min(sn_list) == sn_list[0]:
        sunuke_list.append(counter)
    counter += 1
    sn_list.pop(0)
print(sunuke_list[K-1])

Submission status: Accepted

Solution code:
K =int(input())
a = 0
b = 1

for k in range(K):
  a+=b
  print(a)
  
  if b<(a+b)/sum(map(int,str(a+b))):
    b*=10

Submission status: Accepted

Solution code:
import math

def s(n):
    ret = 0

    while n > 0:
        ret += n % 10
        n = n // 10
        
    return ret

def snuke(n):
    candidate = []

    for d in range(int(math.log(n, 10)) + 2):
        x = n - (n % 10**d) + (10**d - 1)
        candidate.append(x)
    
    min_value = candidate[0] / s(candidate[0])
    ans = candidate[0]
    for c in candidate[1:]:
        tmp = c / s(c)
        if tmp < min_value:
            min_value = tmp
            ans = c
            
    return ans

K = int(input())

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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


def f(x):
    nines = max(0, len(str(x)) - 3)
    base = 10**nines - 1
    d = 10**nines
    snuke = x
    ratio = x / s(x)
    candidate = base + (x-base+d-1) // d * d
    for _ in range(150):
        new_ratio = candidate / s(candidate)
        if new_ratio < ratio:
            snuke = candidate
            ratio = new_ratio
        candidate += d
    return snuke


def main():
    k = int(input())
    snuke = 0
    for _ in range(k):
        snuke = f(snuke+1)
        print(snuke)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
K = int(sys.stdin.readline().rstrip())

ANS = [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]
print(*ANS[:K],sep='\n')

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())

K = I()

A = [i for i in range(1,100)]  # Snuke数の候補

for i in range(13):
    for j in range(100,1000):
        A.append(j*10**i+10**i-1)

A.sort(reverse=True)
B = []
m = 10**18
for a in A:
    x = a/sum(int(i) for i in list(str(a)))
    if x <= m:
        B.append(a)
        m = x

B.reverse()
print(*B[:K],sep='\n')

Submission status: Accepted

Solution code:
def sk(k):
  tk = k
  ret = 0
  while tk!=0:
    ret+=tk%10
    tk//=10
  return ret

ans = []
for i in range(1,100):
  tmp = i/sk(i)
  if len(ans)==0:
    ans.append((i,tmp))
  else:
    l=ans[-1]
    if l[1]>tmp:
      ans[-1]=(i,tmp)
    else:
      ans.append((i,tmp))

for j in range(15):
  for i in range(100,1000):
    n=int(str(i)+''.join(['9']*j))
    tmp=n/sk(n)
    if ans[-1][1] > tmp:
      while ans[-1][1]>tmp:
        ans.pop()
    ans.append((n,tmp))

for i in range(int(input())):
  print(ans[i][0])

Submission status: Accepted

Solution code:
def sk(k):
    tk = k
    ret = 0
    while tk!=0:
        ret+=tk%10
        tk//=10
    return ret
an = []
for i in range(1,100):
    tp = i/sk(i)
    if len(an)==0:an.append((i,tp))
    else:
        ls=an[-1]
        if ls[1]>tp:an[-1]=(i,tp)
        else:an.append((i,tp))
for j in range(15):
    for i in range(100,1000):
        ns=str(i)+''.join(['9']*j)
        nm=int(ns)
        tp=nm/sk(nm)
        if an[-1][1] > tp:
            while an[-1][1]>tp:
                an.pop()
        an.append((nm,tp))
for i in range(int(input())):print(an[i][0])