Problem: 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.

Submission attempts (in order):
MAX = 10**15+1

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(K):
            print(i)
        for i in range(10,K+1):
            ans = find_next_n(n)
            print(ans)
            n = ans+i
            
            if n>MAX:
                break
    
    
if __name__ == "__main__":
    main()

MAX = 10**15+1

def top(num):
    ans = 0
    while num//10 != 0:
        ans += num%10
        num = num//10
    return num


def tail(num):
    sho = num//10
    return num-10*sho

def get_snuke():
        for i in range(1,MAX):
            if i <= 10:
                yield i
            elif  tail(i) == 9:
                if top(i) != top(i+10):
                    yield i
    

def main():
    K = int(input())
    gen = get_snuke()

    
    for _ in range(K):
        snuke_num = gen.__next__()
        print(snuke_num)

if __name__ == "__main__":
    main()

MAX = 10**15+1

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,K+1):
            print(i)
        for i in range(10,K+1):
            ans = find_next_n(n)
            print(ans)
            n = ans+i
            
            if n>MAX:
                break
    
    
if __name__ == "__main__":
    main()

MAX = 10**15+1

def tail(num):
    sho = num//10
    return num-10*sho

def get_snuke():
        for i in range(1,MAX):
            if i <= 10:
                yield i
            elif  tail(i) == 9:
                yield i
    

def main():
    K = 100
    gen = get_snuke()
    
    for _ in range(K):
        snuke_num = gen.__next__()
        print(snuke_num)

if __name__ == "__main__":
    main()

MAX = 10**15+1

def tail(num):
    sho = num//10
    return num-10*sho

def get_snuke():
        for i in range(1,MAX):
            if i <= 10:
                yield i
            elif  tail(i) == 9:
                yield i
    

def main():
    K = int(input())
    gen = get_snuke()
    
    for _ in range(K):
        snuke_num = gen.__next__()
        print(snuke_num)

if __name__ == "__main__":
    main()

import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def ds(n:int):
    return sum([int(i) for i in str(n)])

def snuke(n:int):
    return n/ds(n)

def cands(n:int):
    ret = []
    nl = len(str(n))
    for i in range(nl):
        ret.append(str(n)[:nl-i-1] + "9"*(i+1))
        
    return ret

k = ni()


ans = [i for i in range(1,10)]


cur = 10
while len(ans) < k:
    cand = cands(cur)
    temp = 10**18
    nex = -1
    for c in cand:
        if snuke(int(c)) <= temp:
            temp = snuke(int(c))
            nex = int(c)
            
    ans.append(nex)
    cur = nex+1
    
for ai in ans[:k]:
    print(ai)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted