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: Wrong Answer

Solution code:
k=int(input())
if k<=9:
    for i in range(1,k+1):
        print(i)
else:
    k-=9
    for i in range(1,10):
        print(i)
    for i in range(1,k+1):
        print(i*10+9)

Submission status: Wrong Answer

Solution code:
K = int(input())

for k in range(1,K+1):
    ans = ""
    mod = ""
    ans += "9"*(k//9)
    if k % 9:
        mod = k % 9
    print(str(mod)+ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = ""
mod = ""
ans += "9"*(K//9)
if K % 9:
    mod = K % 9
print(str(mod)+ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


'''
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize = (5, 5))
x = list(range(1, 150))
y = [i/sum([int(str(i)[j]) for j in range(len(str(i)))]) for i in x]
ax.scatter(x, y)
for j in x:
    ax.annotate(s=j, xy=(x[j-1], y[j-1]))
plt.show()
'''

k = I()
if k <= 9:
    for i in range(1, k + 1):
        print(i)
else:
    for i in range(1, 10):
        print(i)
    for j in range(k - 9):
        print((j + 1) * 10 + 9)

Submission status: Wrong Answer

Solution code:
K=int(input())
count=0
s='123456789'
while(count<K):
  a = count%9
  b = count//9
  print(int(s[a]+'9'*b))
  count+=1

Submission status: Wrong Answer

Solution code:
K=int(input())
count=0
s='123456789'
while(count<K):
  a = count%9
  b = count//9
  print(s[a]+'9'*b)
  count+=1

Submission status: Wrong Answer

Solution code:

def resolve():
    K=int(input())
    x=list(range(1,K+1))
    for i in range(9,K):

        x[i]=x[i-9]*10+9
    for i in x:
        print(i)




if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

L = set()
nine = ''
for i in range(16) :
    for j in range(1, 100) :
        x = int(str(j) + nine)
        L.add(x)
    nine += '9'
    
L = list(L)
L.sort()

v = [1]
n = [1]

for l in L[1:] :
    x = l / S(l)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(l)

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

Submission status: Wrong Answer

Solution code:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(1, 16) :
    for j in range(100, 1000) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

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

Submission status: Wrong Answer

Solution code:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 16) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

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

Submission status: Wrong Answer

Solution code:
K = int(input())
if K >= 9:
    for i in range(1, 10):
        print(i)
else:
    for i in range(1, K+1):
        print(i)
        exit()

K = K - 9
for i in range(1, K+1):
    for j in range(2, 11):
        x = (10**i)*j - 1
        print(x)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K >= 9:
    for i in range(1, 10):
        print(i)
else:
    for i in range(1, K+1):
        print(i)
        exit()

K = K - 9
x = 9
for i in range(1, K+1):
    x += 10
    print(x)

Submission status: Wrong Answer

Solution code:
def main():
    s=set()
    for digit in range(16):
        for i in range(1,101):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+11]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()

Submission status: Wrong Answer

Solution code:
def main():
    s=set()
    for digit in range(16):
        for i in range(1,11):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+11]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()

Submission status: Wrong Answer

Solution code:
def main():
    s=set()
    for digit in range(16):
        for i in range(1,1000):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+10]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()

Submission status: Wrong Answer

Solution code:
K = int(input())
if K<=9:
    for i in range(1,K+1):
        print(i)
else:
    for i in range(1,10):
        print(i)
    for i in range(10,K+1):
        print(19+10*(K-10))

Submission status: Wrong Answer

Solution code:
K = int(input())
if K<=9:
    print(K)
else:
    print(19+10*(K-10))

Submission status: Wrong Answer

Solution code:
k = int(input())
ans = 0
for i in range(1,10):
    if(k>0):
        print(i)
        k-=1
ans = 9
while(k>0):
    ans+=10
    print(ans)
    k-=1

Submission status: Wrong Answer

Solution code:
K = int(input())
count = 1
while 1:
    keta = count // 9
    up = count % 9
    st = []
    if up != 0:
        st = [str(up)]
    for i in range(keta):
        st.append('9')
    print(''.join(st))
    count += 1
    if count == K+1:
        break

Submission status: Wrong Answer

Solution code:
k = int(input())

q, mod = divmod(k, 9)

for i in range(q + 1):
    upper = 10 ** i
    lower = upper - 1
    if i == q:
        r = range(1, mod + 1)
    else:
        r = range(1, 10)
    for j in r:
        num = j * upper + lower
        print(num)

Submission status: Wrong Answer

Solution code:
import pprint


N = int(input().strip())

def calc_digit_sum(num):
    ret = 0
    while num > 0:
        ret += num % 10
        num //= 10

    return ret

def calc_digit_sums(K):
    return [[k + n for n in range(10)] for k in range(K)]

# pprint.pprint([(i, i / calc_digit_sum(i)) for i in range(1, 1000)])

# [print(i) for i in range(1, min(N + 1, 10))]
# [print(9 + 10 * i) for i in range(min(N - 9, 10))]
# [print(99 + 100 * i) for i in range(min(N - 19, 10))]

# [[print(10 ** k - 1 + 10 ** k * i) for i in range(1, min(N, 10 * (k + 1) - 1) - (10 * k - 1))] for k in range((N + 10) // 10)]
[[print(str(i) + (str(9) * k)) for i in range(1, min(10, N - 9 * k + 1))] for k in range((N + 10) // 10)]

Submission status: Wrong Answer

Solution code:
import pprint


N = int(input().strip())

def calc_digit_sum(num):
    ret = 0
    while num > 0:
        ret += num % 10
        num //= 10

    return ret

def calc_digit_sums(K):
    return [[k + n for n in range(10)] for k in range(K)]

# pprint.pprint([(i, i / calc_digit_sum(i)) for i in range(1, 200)])

if N <= 9:
    [print(i) for i in range(1, N + 1)]

else:
    [print(i) for i in range(1, 10)]
    [print(9 + 10 * i) for i in range(1, N - 8)]

Submission status: Wrong Answer

Solution code:
k = int(input())
suffix = 0
while k > 0:
    for i in range(1, 10):
        if k > 0:
            print(str(i)+("9"*suffix))
            k -= 1
    suffix += 1

"""
m = 0
for i in range(1,1000):
    j = i / sum(int(x) for x in str(i))
    m = max(j, m)
    print(i, "%-3.3f"%j, m,sep="\t")

    # 19 = 1.9
    # 29 = 2.636
    # 199=10.474
"""

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    K = int(input())
    ans = []
    n = 0
    while(len(ans)<K):
        for i in range(1,10):
            ans.append(str(i)+"9"*n)
        n += 1

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

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    for i in range(min(K, 9)):
        print(i+1)
    if K <= 9:
        return
    q = 1
    joi = 1
    for i in range(K-9):
        print(str(joi)+"9"*q)
        joi += 1
        if joi > 9:
            joi = 1
            q += 1


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

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

def main():
    k = ri()
    cand = list(range(1, 10))
    last = 9
    for n in range(1, 15):
        pow10n = pow(10, n)
        for d in range(1, 10):
            lim = (d+1)*pow10n
            e = 0
            while True:
                e1 = d*pow10n+e*(last+1)+last
                if e1 >= lim:
                    break
                e2 = e1 + (last+1)
                if calc(e1) > calc(e2):
                    last = last*10+9
                    e = 0
                    continue
                cand.append(e1)
                e += 1
    print("\n".join(map(str, cand[:k])))


if __name__ == '__main__':
    main()

"""
1 1.0
2 1.0
3 1.0
4 1.0
5 1.0
6 1.0
7 1.0
8 1.0
9 1.0
19 1.9
29 2.6363636363636362
39 3.25
49 3.769230769230769
59 4.214285714285714
69 4.6
79 4.9375
89 5.235294117647059
99 5.5
199 10.473684210526315
299 14.95
399 19.0
499 22.681818181818183
599 26.043478260869566
699 29.125
799 31.96
899 34.57692307692308
999 37.0
1099 57.8421052631579
1199 59.95
1299 61.857142857142854
1399 63.59090909090909
1499 65.17391304347827
1599 66.625
1699 67.96
1799 69.1923076923077
1899 70.33333333333333
1999 71.39285714285714
2999 103.41379310344827
3999 133.3
4999 161.25806451612902
5999 187.46875
6999 212.0909090909091
7999 235.26470588235293
8999 257.1142857142857
9999 277.75
10999 392.82142857142856
11999 413.7586206896552
12999 433.3
13999 451.5806451612903
14999 468.71875
15999 484.8181818181818
16999 499.97058823529414
17999 514.2571428571429
18999 527.75
19999 540.5135135135135
20999 724.1034482758621
21999 733.3
22999 741.9032258064516
23999 749.96875
24999 757.5454545454545
25999 764.6764705882352
26999 771.4
27999 777.75
28999 783.7567567567568
29999 789.4473684210526
39999 1025.6153846153845
49999 1249.975
59999 1463.3902439024391
69999 1666.642857142857
79999 1860.4418604651162
89999 2045.4318181818182
99999 2222.2
109999 2972.945945945946
119999 3157.8684210526317
129999 3333.3076923076924
139999 3499.975
149999 3658.512195121951
159999 3809.5
169999 3953.4651162790697
179999 4090.8863636363635
189999 4222.2
199999 4347.804347826087
209999 5526.289473684211
219999 5641.0
229999 5749.975
239999 5853.634146341464
249999 5952.357142857143
259999 6046.488372093023
269999 6136.340909090909
279999 6222.2
289999 6304.326086956522
299999 6382.95744680851
309999 7948.692307692308
319999 7999.975
329999 8048.756097560976
339999 8095.214285714285
349999 8139.511627906977
359999 8181.795454545455
369999 8222.2
379999 8260.847826086956
389999 8297.851063829787
399999 8333.3125
499999 10204.061224489797
599999 11999.98
699999 13725.470588235294
799999 15384.596153846154
899999 16981.11320754717
999999 18518.5
"""

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    k = ri()
    cand = list(range(1, 10))
    for n in range(1, 15):
        for d in range(1, 10):
            cand.append(d*pow(10,n)+(pow(10,n)-1))
    print("\n".join(map(str, cand[:k])))


if __name__ == '__main__':
    main()