Problem:


Score : 700 points

Problem Statement

Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.

Constraints

2 \leq K \leq 10^5

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print the smallest possible sum of the digits in the decimal notation of a positive multiple of K.

Sample Input 1

6

Sample Output 1

3

12=6×2 yields the smallest sum.

Sample Input 2

41

Sample Output 2

5

11111=41×271 yields the smallest sum.

Sample Input 3

79992

Sample Output 3

36



Sample input:
6


Sample output:
3

Submission status: Wrong Answer

Solution code:
k = int(input())
a,b ,li=1, 100000,[]
ks = str(k)
n = 0
while a <= b:
    ks = str(k)
    ks = int(ks)*a
    ks = str(ks)
    for i in ks:
        n += int(i)
    li.append(n)
    n = 0
    a += 1
print(min(li))

Submission status: Wrong Answer

Solution code:
k = int(input())
a,b ,li=1, 10000,[]
ks = str(k)
n = 0
while a <= b:
    ks = str(k)
    ks = int(ks)*a
    ks = str(ks)
    for i in ks:
        n += int(i)
    li.append(n)
    n = 0
    a += 1
print(min(li))

Submission status: Wrong Answer

Solution code:
k = int(input())
a,b ,li=1, 1000,[]
ks = str(k)
n = 0
while a <= b:
    ks = str(k)
    ks = int(ks)*a
    ks = str(ks)
    for i in ks:
        n += int(i)
    li.append(n)
    n = 0
    a += 1
print(min(li))

Submission status: Wrong Answer

Solution code:
k = int(input())
a,b ,li=1, 50,[]
ks = str(k)
n = 0
while a <= b:
    ks = str(k)
    ks = int(ks)*a
    ks = str(ks)
    for i in ks:
        n += int(i)
    li.append(n)
    n = 0
    a += 1
print(min(li))

Submission status: Wrong Answer

Solution code:
k = int(input())
a,b ,li=1, 30,[]
ks = str(k)
n = 0
while a <= b:
    ks = int(ks)*a
    ks = str(ks)
    for i in ks:
        n += int(i)
    li.append(n)
    n = 0
    a += 1
print(min(li))

Submission status: Wrong Answer

Solution code:
K = int(input())
cmin = 10**10
for i in range(1,500001):
    s= str(K*i)
    cnt = 0
    for j in range(len(s)):
        cnt += int(s[j])
    cmin = min(cmin,cnt)
print(cmin)

Submission status: Wrong Answer

Solution code:
K = int(input())
cmin = 10**10
for i in range(1,100001):
    s= str(K*i)
    cnt = 0
    for j in range(len(s)):
        cnt += int(s[j])
    cmin = min(cmin,cnt)
print(cmin)

Submission status: Wrong Answer

Solution code:
input = __import__('sys').stdin.readline
K = int(input())
res = float('inf')

for i in range(1, 10000001):
    s = str(K*i)
    S = 0
    
    for i in s:
        S += ord(i)-ord('0')
    
    res = min(res, S)

print(res)

Submission status: Wrong Answer

Solution code:
K = int(input())
res = float('inf')

for i in range(1, 100001):
    s = str(K*i)
    S = 0
    
    for i in s:
        S += ord(i)-ord('0')
    
    res = min(res, S)

print(res)

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=100
for i in range(1,400000):
    ans=min(ans,sum([int(j) for j in str(k*i)]))
print(ans)

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=100
for i in range(1,100000):
    ans=min(ans,sum([int(j) for j in str(k*i)]))
print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
mn = 1000 
while 10**i<k:
    i += 1
for j in range(1,10**i):
    tmp = k*j
    tmp2 = str(tmp)
    l = len(tmp2)
    sm = 0
    for t in range(l):
        sm += int(tmp2[t])
    mn = min(sm,mn)
print(mn)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = float("inf")
for i in range(1,10**6+1):
    tmp = K*i
    tmp = str(tmp)
    tmp2 = 0
    for j in tmp:
        tmp2 += int(j)
    if tmp2 < ans:
        ans = tmp2
print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input());print(min(sum(map(int,str(K*i)))for i in range(1,9**6)))

Submission status: Wrong Answer

Solution code:
K=int(input());print(min(sum(map(int,str(K*i)))for i in range(1,99999)))

Submission status: Wrong Answer

Solution code:
K=int(input());print(min(sum(map(int,str(K*i)))for i in range(1,1000)))

Submission status: Wrong Answer

Solution code:

def wantsum(n):

    nstr = str(n)

    ans = 0

    for j in nstr:
        ans += int(j)

    return ans

def dtdf(n):

    while n % 2 == 0:
        n = n // 2
    while n % 5 == 0:
        n = n // 5

    return n

K = int(input())
minans = float("inf")
K = dtdf(K)

for i in range(3 * (10 ** 5)):

    i += 1
    nsum = wantsum(i * K)

    if minans > nsum:
        minans = nsum
        lasti = i

#print (lasti,K*lasti)
print (minans)

Submission status: Wrong Answer

Solution code:

def wantsum(n):

    nstr = str(n)

    ans = 0

    for j in nstr:
        ans += int(j)

    return ans

def dtdf(n):

    while n % 2 == 0:
        n = n // 2
    while n % 5 == 0:
        n = n // 5

    return n

K = int(input())
minans = float("inf")

for i in range(3 * (10 ** 5)):

    i += 1
    i *= 2
    i -= 1
    nsum = wantsum(i * K)

    if minans > nsum:
        minans = nsum
        lasti = i

#print (lasti,K*lasti)
print (minans)

Submission status: Wrong Answer

Solution code:

def wantsum(n):

    nstr = str(n)

    ans = 0

    for i in nstr:
        ans += int(i)

    return ans

def dtdf(n):

    while n % 2 == 0:
        n = n // 2
    while n % 5 == 0:
        n = n // 5

    return n

K = int(input())
minans = float("inf")

for i in range(3 * (10 ** 5)):

    i += 1
    nsum = wantsum(i * K)

    if minans > nsum:
        minans = nsum
        lasti = i

#print (lasti,K*lasti)
print (minans)

Submission status: Wrong Answer

Solution code:

def wantsum(n):

    nstr = str(n)

    ans = 0

    for i in nstr:
        ans += int(i)

    return ans

def dtdf(n):

    while n % 2 == 0:
        n = n // 2
    while n % 5 == 0:
        n = n // 5

    return n

K = int(input())
minans = float("inf")

for i in range(10 ** 6):

    i += 1
    nsum = wantsum(i * K)

    if minans > nsum:
        minans = nsum
        lasti = i

#print (lasti,K*lasti)
print (minans)

Submission status: Wrong Answer

Solution code:
K = int(input())

while K % 2 == 0 :
    K //= 2
    
while K % 5 == 0 :
    K //= 5

m = float('inf')
for i in range(1, 100001) :
    KK = list(str(K * i))
    ret = sum(map(int, KK))
    if ret < m :
        m = ret
print(m)

Submission status: Wrong Answer

Solution code:
K = int(input())

while K % 2 == 0 :
    K //= 2

m = float('inf')
for i in range(1, 100001) :
    KK = list(str(K * i))
    ret = sum(map(int, KK))
    if ret < m :
        m = ret
print(m)

Submission status: Wrong Answer

Solution code:
K = int(input())

m = float('inf')
for i in range(1, 1000000) :
    kk = str(K * i)
    ret = 0
    for j in kk :
        ret += int(j)
    m = min(m, ret)
print(m)

Submission status: Wrong Answer

Solution code:
K = int(input())

m = float('inf')
for i in range(1, 100000) :
    kk = str(K * i)
    ret = 0
    for j in kk :
        ret += int(j)
    m = min(m, ret)
print(m)

Submission status: Wrong Answer

Solution code:
K = int(input())

m = float('inf')
for i in range(1, 10000) :
    kk = str(K * i)
    ret = 0
    for j in kk :
        ret += int(j)
    m = min(m, ret)
print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = float('inf')
for i in range(1,10):
    x = 0
    for c in str(N*i):
        x += int(c)
    ans = min(x,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

k = int(input())

g = [[] for _ in range(k)]
for i in range(k):
    g[i].append(((i+1)%k,1))
    if i: g[i].append((10*i%k,0))

#print(g)
from collections import deque
q = deque([1])
INF = float("inf")
res = [INF]*k
res[1] = 1
while q and res[0] == INF:
#    print(q)
    v = q.popleft()
    for c,d in g[v]:
        if res[c] <= res[v] + d: continue
        res[c] = res[v] + d
        if d: q.append(c)
        else: q.appendleft(c)

#print(res)
print(res[0])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

k = int(input())

g = [[] for _ in range(k)]
for i in range(k):
    g[i].append(((i+1)%k,1))
    if i: g[i].append((10*i%k,0))

#print(g)
from collections import deque
q = deque([0])
res = [0]*k
used = [0]*k
while q and not used[0]:
#    print(q)
    v = q.popleft()
    for c,d in g[v]:
        if used[c]: continue
        res[c] = res[v] + d
        used[c] = 1
        if d == 0: q.appendleft(c)
        else: q.append(c)

#print(res)
#print(used)
print(res[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC77 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def factorization(n):
    f = defaultdict(lambda : 0)
    tmp = n
    for i in range(2,int(math.sqrt(n))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            f[i] += cnt
    if tmp != 1:
        f[tmp] += 1
    if all(f) == 0:
        f[n] += 1

    return f

k = I()
p = factorization(k)
p[2],p[5] = 0,0
tmp = 1
for i,j in p.items():
    if j != 0:
        tmp *= i**j
ans = sum(list(map(int,(list(str(tmp))))))
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
def count(n):
  return sum(map(int, list(str(n))))
while K%2 == 0:
  K = K//2
while K%5 == 0:
  K = K//5
r = count(K)
for i in range(1, K+1):
  n = K*i
  c = count(n)
  if c < r:
    r = c
print(r)

Submission status: Wrong Answer

Solution code:
K = int(input())
def count(n):
  return sum(map(int, list(str(n))))
while K%2 == 0:
  K = K//2
while K%5 == 0:
  K = K//5
r = count(K)
for i in range(1, 10):
  n = K*i
  c = count(n)
  if c < r:
    r = c
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
tmp=n
ans=0
if n%2==0:
    while tmp%10 != 0:
        tmp += n
    while tmp != 0:
        ans += tmp %10
        tmp //=10
    print(ans)
else:
    while tmp%10 != 1:
        tmp += n
    while tmp != 0:
        ans += tmp %10
        tmp //=10
    print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
k=2*K
l=[]

def f(x):
  ans=0
  while x>0:
    ans+=(x%10)
    x//=10
  return ans

l.append(f(K))
    
while f(k)!=f(K):
  l.append(f(k))
  k+=K

L=sorted(l)
print(L[0])

Submission status: Wrong Answer

Solution code:
K=int(input())
k=2*K
l=[]

def f(x):
  ans=0
  while x>0:
    ans+=(x%10)
    x//=10
  return ans

l.append(f(K))
    
while f(k)!=f(K):
  l.append(f(k))
  k+=K
  
print(min(l))

Submission status: Wrong Answer

Solution code:
from collections import deque

K = int(input())

G = [None]*K
for i in range(K):
    G[i] = ((10*i % K, 0), ((i+1) % K, 1))
s = 1

dist = [-1] * K
que = deque([s])
dist[s] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w, c in G[v]:
        if dist[w] != -1:
            continue
        dist[w] = d+c
        if c:
            que.append(w)
        else:
            que.appendleft(w)

print(dist[0]+1)

Submission status: Wrong Answer

Solution code:
from math import ceil
from math import log
K=int(input())
N=K
def func(N):
    res=0
    while(N!=0):
        res+=N%10
        N//=10
    return res
ans=func(K)
if ans==1:
    print(ans)
    quit()
n=ceil(log(K,10))
MOD=10**(n)
K=K*(ceil((10**n)/K))
ans=min(ans,func(K))
used=[0]*N
K%=MOD
K*=10
while(True):
    K%=N
    if K==0:
        print(1)
        quit()
    ans=min(ans,func(K)+1)
    if used[K]:
        print(ans)
        quit()
    used[K]=1
    K*=10

Submission status: Wrong Answer

Solution code:
def solve(num):
    while num % 2 == 0:
        num = num // 2
    while num % 5 == 0:
        num = num // 5
    return min([(sum(map(int,str(num*(i+1)))), num*(i+1)) for i in range(100000)])

print(solve(int(input()))[0]
)

Submission status: Wrong Answer

Solution code:
def solve(num):
    while num % 2 == 0:
        num = num // 2
    while num % 5 == 0:
        num = num // 5
    return min([(sum(map(int,str(num*(i+1)))), num*(i+1)) for i in range(100000)])

solve(int(input()))[0]

Submission status: Wrong Answer

Solution code:
def solve(num):
    while num % 2:
        num = num // 2
    while num % 5:
        num = num // 5
    return min([(sum(map(int,str(num*(i+1)))), num*(i+1)) for i in range(100000)])

solve(int(input()))

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from collections import deque
    K = I()
    edge = [[]for _ in range(K)]
    for i in range(K):
        edge[i].append((i * 10) % K)
        edge[i].append((i + 1)%K)
        
    zero_one_deque = deque([1])
    node = [inf] * K
    #1から始めて、Kの倍数を見つける 01BFS
    node[1] = 1
    while zero_one_deque:
        from_ = zero_one_deque.popleft()
        for i, to in enumerate(edge[from_]):
            if node[to] != inf:
                continue
            node[to] = node[from_]
            if i == 0:
                zero_one_deque.appendleft(to)
            else:   
                node[to] += 1
                zero_one_deque.append(to)
    print(node[0])
                    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from collections import deque
    K = I()
    edge = [[]for _ in range(K)]
    for i in range(K):
        edge[i].append((i * 10) % K)
        edge[i].append((i + 1)%K)
        
    zero_one_deque = deque([1])
    node = [inf] * K
    node[1]=1
    for i in range(K+1):
        tmp = deque()
        while zero_one_deque:
            from_ = zero_one_deque.popleft()
            for i, to in enumerate(edge[from_]):
                if node[to] != inf:
                    continue
                node[to] = node[from_]
                if i == 0:
                    tmp.appendleft(to)
                else:   
                    node[to] += 1
                    tmp.append(to)
        zero_one_deque = tmp
    print(node[0])
                    

            
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from collections import deque
    K = I()
    edge = [[]for _ in range(K)]
    for i in range(K):
        edge[i].append((i * 10) % K)
        edge[i].append((i + 1)%K)
        
    zero_one_deque = deque([1])
    node = [inf] * K
    node[1]=1
    for i in range(K):
        tmp = deque()
        while zero_one_deque:
            from_ = zero_one_deque.popleft()
            for i, to in enumerate(edge[from_]):
                if node[to] != inf:
                    continue
                node[to] = node[from_]
                if i == 0:
                    tmp.appendleft(to)
                else:   
                    node[to] += 1
                    tmp.append(to)
        zero_one_deque = tmp
    print(node[0])
                    

            
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def loop(i):
    j = (10 * i) % K
    if dp[i] < dp[j-1] + 1 and dp[i] < dp[j]:
        dp[j] = dp[i]
        return j, True
    if dp[j-1] + 1 < dp[i] and dp[j-1] + 1 < dp[j]:
        dp[j] = dp[j-1] + 1
        return j, True
    return j, False


K = int(input())

dp = [K + 1 for _ in range(K)]

dp[1] = 1
for i in range(1, K):
    if dp[i] != K + 1 and i != 1:
        continue
    if i != 1:
        dp[i] = dp[i-1] + 1
    l = i
    while True:
        l, updated = loop(l)
        if not updated:
            break

dp[0] = min(dp[K - 1] + 1, dp[0])
print(dp[0])

Submission status: Wrong Answer

Solution code:
from collections import deque
K=int(input())#modKのグラフ
Link=[[] for i in range(K)]
for i in range(K):
    Link[i].append((i+1)%K)
    Link[i].append((i*10)%K)
#BFSで1から0へ
went=[False]*K
went[1]=True
queue=deque()
queue.append((1,0))
while queue:
    cur,dim = queue.popleft()
    if cur==0:
        print(dim+1)
        break
    for distzero,togo in enumerate(Link[cur]):
        if not went[togo]:
            went[togo] = True
            if distzero:
                queue.appendleft((togo,dim))
            else:
                queue.append((togo,dim+1))

Submission status: Wrong Answer

Solution code:
from collections import deque
K=int(input())#modKのグラフ
Link=[[] for i in range(K)]
for i in range(K):
    Link[i].append((i+1)%K)
    Link[i].append((i*10)%K)
#BFSで1から0へ
went=[False]*K
went[1]=True
queue=deque()
queue.append((1,0))
while queue:
    cur,dim = queue.popleft()
    if cur==0:
        print(dim+1)
        break
    for n,togo in enumerate(Link[cur]):
        if not went[togo]:
            went[togo] = True
            queue.append((togo,dim+(n==0)))

Submission status: Wrong Answer

Solution code:
k = int(input())
graph = dict()
for i in range(k):
    graph[i] = []
for i in range(k):
    graph[i].append([(i+1)%k,1])
    graph[i].append([(i*10)%k,0])

q = [1]
arrival = [-1 for i in range(k)]
while len(q) != 0:
    if arrival[q[0]] == -1:
        arrival[q[0]] = 0
    for i in range(len(graph[q[0]])):
        if arrival[graph[q[0]][i][0]] == -1:
            arrival[graph[q[0]][i][0]] = arrival[q[0]] + graph[q[0]][i][1]
            q.append(graph[q[0]][i][0])
        else:
            if arrival[graph[q[0]][i][0]] > arrival[q[0]] + 1:
                arrival[graph[q[0]][i][0]] = arrival[q[0]] + graph[q[0]][i][1]
                q.append(graph[q[0]][i][0])
    q.pop(0)

print(arrival[0]+1)

Submission status: Wrong Answer

Solution code:
k = int(input())
from collections import deque
d = deque([1])
discovered = {1:1}
while True:
  q = d.popleft()
  if q == 0: 
  	print(discovered[q])
  	quit()
  if (q*10)%k not in discovered:
    d.appendleft((q*10)%k)
    discovered[(q*10)%k] = discovered[q]
  if (q+1)%k not in discovered:
    d.append(q+1)
    discovered[q+1] = discovered[q]+1

Submission status: Wrong Answer

Solution code:
k = int(input())
from collections import deque
d = deque([1])
discovered = {1:1}
while True:
  q = d.popleft()
  if q == 0: 
  	print(discovered[q])
  	quit()
  if (q*10)%k not in discovered:
    d.appendleft((q*10)%k)
    discovered[(q*10)%k] = discovered[q]
  if q+1 not in discovered:
    d.append(q+1)
    discovered[q+1] = discovered[q]+1

Submission status: Wrong Answer

Solution code:
K = int(input())
print(min([sum([int(j) for j in list(str(K*i))]) for i in range(1, 10**(len(str(K))))]))

Submission status: Wrong Answer

Solution code:
K = int(input())
print(min([sum([int(j) for j in list(str(K*i))]) for i in range(1, 10**len(str(K)))]))

Submission status: Wrong Answer

Solution code:
K = int(input())
print(min([sum([int(j) for j in list(str(K*i))]) for i in range(1, K)]))

Submission status: Wrong Answer

Solution code:
calc =  lambda x : sum([int(char) for char in str(x)])
import math

k = int(input())


m = 1e9
for i in range(1, 10**(math.ceil(math.log10(k)) +1)):
  c = calc(i * k)
  if m > c:
    m = c
print(m)

Submission status: Wrong Answer

Solution code:
calc =  lambda x : sum([int(char) for char in str(x)])
import math

k = int(input())


m = 1e9
for i in range(1, 10**math.ceil(math.log10(k)) ):
  c = calc(i * k)
  if m > c:
    m = c
print(m)

Submission status: Wrong Answer

Solution code:
def sum_keta(num):
    ans = 0
    for i in str(num):
        ans = ans + int(i)
    return ans

k = int(input())
num = 0
ans = 10**5
for i in range(10**6 + 1):
    num += k
    ans = min(ans, sum_keta(num))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
print(min([ sum([ int(i) for i in list(str(i*n)) ]) for i in range(2,10**5+1) ]))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(10000)
INF = float('inf')

K = int(input())

# ある数に 1 を足すと各桁の和は 1 増える
# ある数に 10 を掛けると各桁の和は 0 増える
# mod K の世界で同じことやっても同じなので
# このグラフ上で 1 から 0 への最短距離が答え。

distances = [INF for _ in range(K)]

# 01BFS
distances[1] = 1
remains = deque()
remains.append((1, 1))
while distances[0] == INF:
    d, mod_k = remains.popleft()
    if d + 1 < distances[(mod_k + 1) % K]:
        distances[(mod_k + 1) % K] = d + 1
        remains.append((d + 1, (mod_k + 1) % K))
    if d < distances[mod_k * 10 % K]:
        distances[mod_k * 10 % K] = d
        remains.appendleft((d, mod_k * 10 % K))
print(distances[0])

Submission status: Wrong Answer

Solution code:
p = int(input())
if ( p%5==0 and p%2==0 ):
  print (1)
else:
  m = 1000000000000000
  for i in range(1,100001):
      v = p*i
      s = 0
      for j in range(10000):
          s += v%10
          v //=10
          if (v==0):
              break
      if (v>=100000):
        s+=1
      m = min(m,s)
  print (m)

Submission status: Wrong Answer

Solution code:
p = int(input())
m = 1000000000000000000
for i in range(1,1000000):
    v = p*i
    s = 0
    for j in range(10000):
        s += v%10
        v //=10
        if (v==0):
            break
    m = min(m,s)
print (m)

Submission status: Wrong Answer

Solution code:
K=int(input())
ans=len(str(K))*9
for i in range(1,6*10**5):
    a=list(str(K*i))
    a2=list(map(int,a))
 
    ans=min(ans,sum(a2))
 
print(ans)

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import itertools
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford, floyd_warshall
#sys.setrecursionlimit(10000)

#H, W = [int(i) for i in input().split()]
N = int(input())

rows = []
cols = []
weights = []

"""
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)
"""

for i in range(N):

    rows.append(i)
    cols.append((i+1)%N)
    weights.append(1)

    rows.append(i)
    cols.append((10*i)%N)
    weights.append(0)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
#graph = coo_matrix((weights, (cols, rows)), shape=(10, 10)).tocsr()
#print(graph)

d1 = dijkstra(graph, indices=1, directed=True, unweighted=False)

print(int(d1[0]+1.5))

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import itertools
from scipy.sparse import csr_matrix, coo_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford, floyd_warshall
#sys.setrecursionlimit(10000)

#H, W = [int(i) for i in input().split()]
N = int(input())

rows = []
cols = []
weights = []

"""
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)
"""

for i in range(N):

    rows.append(i)
    cols.append((i+1)%N)
    weights.append(1)

    rows.append(i)
    cols.append((10*i)%N)
    weights.append(0)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
#graph = coo_matrix((weights, (cols, rows)), shape=(10, 10)).tocsr()
#print(graph)

d1 = dijkstra(graph, indices=1, directed=True, unweighted=False)

print(int(d1[0]+1))

Submission status: Wrong Answer

Solution code:
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == INF:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] > V[i]+1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

Submission status: Wrong Answer

Solution code:
from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == INF:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] == INF:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

Submission status: Wrong Answer

Solution code:
from collections import deque
K = int(input())
V = list(range(K))
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
data = [-1] * (K)
data[1] = 1
q = deque([1])
i = 1
while data[0] == -1:
    i = q.popleft()
    if data[E[i][0]] == -1:
        q.appendleft(E[i][0])
        data[E[i][0]] = data[i]
    if data[E[i][1]] == -1:
        q.append(E[i][1])
        data[E[i][1]] = data[i]+1
print(data[0])

Submission status: Wrong Answer

Solution code:
from collections import deque
K = int(input())
V = list(range(K))
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
data = [-1] * (K)
data[1] = 1
q = deque([1])
i = 1
while i != 0:
    i = q.popleft()
    if data[E[i][0]] == -1:
        q.appendleft(E[i][0])
        data[E[i][0]] = data[i]
    if data[E[i][1]] == -1:
        q.append(E[i][1])
        data[E[i][1]] = data[i]+1
print(data[i])

Submission status: Wrong Answer

Solution code:
K = int(input())
def f(n):
    return n if n<10 else (n%10 + f(n//10))
ans = f(K)
for i in range(2,max(10,K+1)):
    ans = min(ans,f(K*i))
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
def f(n):
    return n if n<10 else (n%10 + f(n//10))
ans = f(K)
for i in range(2,K):
    ans = min(ans,f(K*i))
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
def f(n):
    return n if n<10 else (n%10 + f(n//10))
ans = f(K)
for i in range(2,10):
    ans = min(ans,f(K*i))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

k=int(input())
a_t=1/k
a=a_t*10**(len(str(k))-1)
c=100
buf=0
index=0
b=a
for i in range(1,10):
        b=b-math.floor(b)
        buf=math.floor(b*10)
        #print(i,buf)
        if c>buf:
                index=i
        c=min(c,buf)
        b=b*10
#print(index)
m=math.ceil(a*10**index)
#print(m)
product=k*m
print(sum(int(i) for i in str(product)))

Submission status: Wrong Answer

Solution code:
k = input().rstrip()
if int(k) % 9 == 0:
    print(sum([int(item) for item in k]))
    exit()

k = sum([int(item) for item in k])
ans = 10**5
for i in range(1,10**3):
    ans = min(ans, sum([int(item) for item in str(k*i)]))
print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())

ans = 10**5
for i in range(1,10**5):
    ans = min(ans, sum([int(item) for item in str(k * i)]))

print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())

ans = 10**5
for i in range(1,10):
    ans = min(ans, sum([int(item) for item in str(k * i)]))

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import exit
# A,B,C = [int(n) for n in input().split()]

# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
N = int(input())
K = 10**5
i = 1
ss = set()
while(i != K):
    s = list(str(N*i))
    # print(s)
    tmp = 0
    for j in range(len(s)):
        tmp+=int(s[j])
    # print(tmp)
    ss.add(tmp)
    i+=1
print(sorted(list(ss))[0])

Submission status: Wrong Answer

Solution code:
k = int(input())

a = [0]*(10**6)
b = [0]*(10**6)
for i in range(10**6):
    b[i] = (b[(i+1)//10]+k//10)+k%10
    a[i] = sum([int(c) for c in str(b[i])])

print(min(a))

Submission status: Wrong Answer

Solution code:
k = int(input())

a = [0]*(10**5)

for i in range(10**5):
    a[i] = sum([int(c) for c in str(k*(i+1))])

print(min(a))

Submission status: Wrong Answer

Solution code:
K=input()
L=len(K)
now=0
K=int(K)
ans=float('inf')
for i in range(1,10**(L+1)):
    if ans==1:break
    now+=K
    S=str(now)
    res=0
    for s in S:
        res+=int(s)
    ans=min(ans,res)
print(ans)

Submission status: Wrong Answer

Solution code:
K=input()
L=len(K)
now=0
K=int(K)
ans=float('inf')
for i in range(1,10**5):
    if ans==1:break
    now+=K
    S=str(now)
    res=0
    for s in S:
        res+=int(s)
    ans=min(ans,res)
print(ans)

Submission status: Wrong Answer

Solution code:
K=input()
L=len(K)
now=0
K=int(K)
ans=float('inf')
for i in range(1,10**L):
    if ans==1:break
    now+=K
    S=str(now)
    res=0
    for s in S:
        res+=int(s)
    ans=min(ans,res)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque


def solve(K):
    s = 1
    q = deque()
    q.append(s)
    dists = {}
    dists[s] = 1
    while len(q) > 0:
        n = q.pop()
        if n == 0:
            break
        m = (n*10)%K
        if m not in dists:
            dists[m] = dists[n]
            q.append(m)
        elif dists[m] > dists[n]:
            dists[m] = dists[n]
            q.appendleft(m)
        if n % 10 != 9:
            m = (n+1)%K
            if m not in dists:
                dists[m] = dists[n] + 1
                q.appendleft(m)
            elif dists[m] > dists[n] + 1:
                dists[m] = dists[n] + 1
                q.appendleft(m)
    return dists[0]


def main():
    K = int(input())
    print(solve(K))


if __name__ == '__main__':
    main()