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:
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,1009999999999999,1019999999999999,1029999999999999,1039999999999999,1049999999999999,1059999999999999,1069999999999999,1079999999999999,1089999999999999,1099999999999999,1109999999999999,1119999999999999,1129999999999999,1139999999999999,1149999999999999,1159999999999999,1169999999999999,1179999999999999,1189999999999999,1199999999999999,1299999999999999,1399999999999999,1499999999999999,1599999999999999,1699999999999999,1799999999999999,1899999999999999,1999999999999999,2099999999999999,2199999999999999,2299999999999999,2399999999999999,2499999999999999,2599999999999999,2699999999999999,2799999999999999,2899999999999999,2999999999999999,3099999999999999,3199999999999999,3299999999999999,3399999999999999,3499999999999999,3599999999999999,3699999999999999,3799999999999999,3899999999999999,3999999999999999,4099999999999999,4199999999999999,4299999999999999,4399999999999999,4499999999999999,4599999999999999,4699999999999999,4799999999999999,4899999999999999,4999999999999999,5099999999999999,5199999999999999,5299999999999999,5399999999999999,5499999999999999,5599999999999999,5699999999999999,5799999999999999,5899999999999999,5999999999999999,6099999999999999,6199999999999999,6299999999999999,6399999999999999,6499999999999999,6599999999999999,6699999999999999,6799999999999999,6899999999999999,6999999999999999,7099999999999999,7199999999999999,7299999999999999,7399999999999999,7499999999999999,7599999999999999,7699999999999999,7799999999999999,7899999999999999,7999999999999999,8099999999999999,8199999999999999,8299999999999999,8399999999999999,8499999999999999,8599999999999999,8699999999999999,8799999999999999,8899999999999999,8999999999999999,9099999999999999,9199999999999999,9299999999999999,9399999999999999,9499999999999999,9599999999999999,9699999999999999,9799999999999999,9899999999999999,9999999999999999]

k=int(input())

for i in range(k):
    print(ans[i])

Submission status: Accepted

Solution code:
# D
K = int(input())

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

def next_snuke(k):
    strk = list(str(k))
    add = 1
    for i in range(1, len(strk)+1):
        if strk[-i] != "9":
            add = 10**(i-1)
            break
    return k+add

def is_snuke(n):
    if snuke(n) <= snuke(next_snuke(n)):
        return True
    else:
        return False
    
n = 1
while K > 0:
    print(n)
    K -= 1
    for l in range(len(str(n))+1):
        if is_snuke(n + 10**l):
            n = n + 10**l
            break

Submission status: Accepted

Solution code:
args = int(input().rstrip())

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

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        p = 0
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
                p = power
                break
        if push:
            result.append(i)
        i=i+10**p
            
    return result

arr = find_snuke(args)
for a in arr:
   print(a)

Submission status: Accepted

Solution code:
K = int(input())
for i in range(min(K//9,3)):
    for j in range(9):
        print(str(j+1)+('9'*i))
if K <= 27:
    for i in range(K%9):
        print(str(i+1) + '9'*(K//9))
else:
    c = 27
    keta = 4
    while c < K:
        n = 1
        while True:
            if 10**(n-1) <= 9*keta < 10**n:
                break
            n += 1
        for i in range(10**(n-1),10**n):
            s = str(i)
            array = list(map(int, list(s)))
            n9 = 0
            for w in str(i)[::-1]:
                if w == '9':
                    n9 += 1
                else:
                    break
            if i < (9*(keta-n)+sum(array))*10**n9:
                print(str(i)+'9'*(keta-n))
                c += 1
                if c == K:
                    break
        keta += 1

Submission status: Accepted

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

def cands():
    d = 1
    res = []
    res.extend(range(1, 1000))
    for d in range(3, 16):
        y = 10 ** (d-2)
        z = y - 1
        r = map(lambda x: x * y + z, range(100, 1000))
        res.extend(r)
    return res


def S(m):
    res = 0
    while m > 0:
        res += m % 10
        m //= 10
    return res

def is_snuke(i_s_i, m):
    return i_s_i <= m

ss = []
cs = cands()
for i in cs:
    s_i = S(i)
    ss.append((i, s_i, i / s_i))

m = float('inf')
ms = []
for _, _, i_s_i in reversed(ss):
    m = min(m, i_s_i)
    ms.append(m)
ms = list(reversed(ms))

res = 0
for (i, s_i, i_s_i), m in zip(ss, ms):
    b = is_snuke(i_s_i, m)
    if b:
        print(i)
        res += 1
    if K <= res:
        break

Submission status: Accepted

Solution code:
def digit_sum(a):
    res = 0
    while a:
        res += a % 10
        a /= 10
        a = int(a)
    return res

def main():

    d = {}
    MAX = 10**17
    for i in range(18):
        for j in range(1000):
            if i == 0 and j == 0: continue
            tmp = int(str(j) + str(9) * i)
            if tmp > MAX: continue
            d[tmp] = tmp / digit_sum(tmp)

    ls = []
    for a, b in d.items():
        ls.append([b, a])
    ls.sort()

    ls.append([0, MAX])

    k = int(input())

    idx, last = 0, 0
    while k:
        while ls[idx][1] < last: idx += 1
        print(ls[idx][1])
        k -= 1
        last = ls[idx][1]
        idx += 1

    """while True:
        k = int(input())
        if k == 0:
            return True
        print(">", k / digit_sum(k))
    """

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def S(n):
    return sum(int(x) for x in str(n))
rest = K = int(input())

ans = list(range(1, 10))

rest -= 9
suffix = 10
i = 0
while rest > 0:
    num = int(str(suffix) + '9' * i)
    if suffix % 10 == 0:
        next_suffix = suffix + 9
        next_num = int(str(next_suffix) + '9' * i)
        if num / S(num) > next_num / S(next_num):
            i += 1
            suffix //= 10
        num = int(str(suffix) + '9' * i)
    ans.append(num)
    rest -= 1
    suffix += 1

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    k = I()
    a = set(list(range(1,10)))
    for i in range(1,16):
        for j in range(1,20*i):
            a.add(int('{}{}'.format(j,'9'*i)))
    m = inf
    for c in sorted(list(a))[::-1]:
        t = 0
        n = c
        while n > 0:
            t += n % 10
            n //= 10
        tm = c / t
        if m < tm - eps:
            a.remove(c)
        else:
            m = tm
    l = sorted(list(a))
    return '\n'.join(map(str,l[:k]))


print(main())

Submission status: Accepted

Solution code:
def get_value(n):
    return int(n) / sum(map(int, n))


def solve(k):
    buf = set()
    for z in range(14):
        suffix = '9' * z
        for h in range(1, 10000):
            n = str(h) + suffix
            buf.add((get_value(n), int(n)))
    buf = sorted(buf)
    tmp_max = 0
    ret = []
    for v, n in buf:
        if tmp_max > n:
            continue
        ret.append(str(n))
        tmp_max = n
    return ret[:k]


k = int(input())
print('\n'.join(solve(k)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
K = int(input())
a = 0
d = 1
def snuke(x):
    a = 0
    while x>0:
        a += x%10
        x //= 10
    return a
for i in range(1, K+1):
    x = a + d
    y = a + 10*d
    if x/snuke(x) <= y/snuke(y):
        a = x
    else:
        a = y
        d *= 10
    print(a)

Submission status: Accepted

Solution code:
def S(n):
    return sum(int(x) for x in str(n))
rest = K = int(input())

ans = list(range(1, 10))

rest -= 9
suffix = 10
i = 0
while rest > 0:
    num = int(str(suffix) + '9' * i)
    if suffix % 10 == 0:
        while suffix % 10 == 0:
            next_suffix = suffix + 9
            next_num = int(str(next_suffix) + '9' * i)
            if num / S(num) > next_num / S(next_num):
                i += 1
                suffix //= 10
            else:
                break
        num = int(str(suffix) + '9' * i)
    ans.append(num)
    rest -= 1
    suffix += 1

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

Submission status: Accepted

Solution code:
K = int(input())

Ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for x in range(1,15):
    B = [0]*100000
    n,d = 10**x,int("9"*x)
    for i in range(10000):
        num = i*n+d
        S = str(num)
        total = 0
        for s in S:
            total += int(s)
        B[i] = num/total
        if i > 0:
            if B[i] < B[i-1]:
                #最後の値を削除
                Ans.pop()
                break
            else:
                if num not in Ans:
                    Ans.append(num)

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

Submission status: Accepted

Solution code:
def s(x):
    ans =0
    for c in str(x):
        ans += int(c)
    return(ans)
def snuke(x):
    return x/s(x)
def next(x,delta):
    return (x//delta + 1) * delta - 1

K = int(input())
ans = [1,2,3,4,5,6,7,8,9]
delta = 10
L = K-9
x=19
while L>0:
    if delta*s(x) >= x:
        ans.append(x)
        L -= 1
        x += delta
    else:
        delta *= 10
        x = next(x,delta)
for i in range(K):
    print(ans[i])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def sum_digits(n,m):
    r = 0
    while n:
        r, n = r + n % m, n // m
    return r

def sunuke(n):
    return sum_digits(n,10)/n

#n,k = [int(i) for i in input().split()]
#a = [int(i)-1 for i in input().split()]
k=int(input())

#a=[]
#for i in range(999,8022,100):
#    a.append([i,sum_digits(i,10)/i])
#print(a)

c=0
sentou = 0
N=0
keta = 0 #
while(c<k):
    c+=1

    N+=10**keta
    if sentou < 9:
        sentou+=1
    else:
        while(sunuke(N) < 1/(10**keta)):
            N+=9*(10**keta)
            keta+=1
        sentou = (N//(10**keta))%10
#    print(N,keta,sentou)
    print(N)

Submission status: Accepted

Solution code:
def f(n):
    summ = 0 
    for ele in str(n):
        summ+=(int(ele))
    return n/summ
    
l = []

for i in range(1,10):
    l.append(i)

st = 19 
diff = 10 
while True:
    if f(st)<=f(st+diff):
        l.append(st)
    else:
        st-=diff
        diff*=10
    st+=diff
    if st>10**16:
        break
print(*l[:int(input())],sep='\n')

Submission status: Accepted

Solution code:
def digit_sum(i):
    return sum(map(int, list(str(i))))

def score(head, tail):
    return num(head, tail)/digit_sum(num(head, tail))

def num(head, tail):
    return int(str(head)+tail)

k = int(input())
tail = ''
head = 0
cnt = 0
last = 0
while True:
    head += 1
    if score(head, tail) <= score(head+1, tail):
        if num(head, tail) > last:
            print(str(head)+tail)
            last = num(head, tail)
            cnt += 1
            if cnt == k:
                break
    else:
        head = 0
        tail += '9'

Submission status: Accepted

Solution code:
def calc(n):
    if n == 0:
        return -1
    s = 0
    n_ = n
    while n:
        s += n%10
        n //= 10
    return n_/s

# res = []
# for i in range(1,10**6):
#     res.append((i/sunuke(i), i))
#     # print(i, i/sunuke(i))
# res.sort()
# max_i = 0
# ret = []
# for v, i in res:
#     if i > max_i:
#         max_i = i
#         print(i, v)
#         ret.append(i)
# print(ret)

k = int(input())
for i in range(1, min(9,k)+1):
    print(i)
cnt = min(9,k)
i = min(9,k)
d = 1

while cnt < k:
    # print(i,d)
    while calc(i+d) > calc(i+d*10):
        d *= 10
    i +=d
    print(i)
    cnt += 1

# vv = [30999,39999]
# for v in vv:
#     print(v, v/sunuke(v), 10)