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())
def digitsum(n):
  nstr = str(n)
  sum = 0
  for c in nstr:
    sum += int(c)
  return sum,len(nstr)

minimum, width = digitsum(K)
while minimum > width:
  K *= 2
  sum, w = digitsum(K)
  width = w
  minimum = min(sum, minimum)

print(minimum)

Submission status: Wrong Answer

Solution code:
k=input()
print min([sum(map(int, list(str(k*i)))) for i in xrange(1, 10**5)])

Submission status: Wrong Answer

Solution code:
k=input()
print min([sum(map(int, list(str(k*i)))) for i in xrange(1, 10**(len(str(k))+1))])

Submission status: Wrong Answer

Solution code:
k = input()
print min([sum(map(int, list(str(k*i)))) for i in xrange(1, 10**len(str(k)))])

Submission status: Wrong Answer

Solution code:
k = input()
print min([sum(map(int, list(str(k*i)))) for i in xrange(1, 10)])

Submission status: Wrong Answer

Solution code:
from collections import deque
v, que, k = set(), deque([(1, 1)]), input()
while que:
    n, c = que.popleft()
    if n in (0, k):
        print c
        break
    if n not in v:
        que.append(((n + 1) % k, c + 1))
        que.append(((n * 10) % k, c))
        v.add(n)

Submission status: Wrong Answer

Solution code:
def digsum(n):
    t = 0
    while n>0:
        t += n%10
        n /= 10
    return t

n = int(raw_input())
best = digsum(n)
for i in xrange(2,10**len(str(n))):
    d = digsum(n*i)
    if d < best:
        best = d
print best

Submission status: Wrong Answer

Solution code:
k = input()
if k > 9:
    record = [[0, False] for x in xrange(k + 1)]
    for i in xrange(1, k + 1):
        if record[k][1]:
            break
        try:
            if not record[i + 1][1] and i % 10 != 9:
                record[i + 1][0] = record[i][0] + 1
                record[i + 1][1] = True
        except:
            pass
        try:
            if not record[i * 10][1]:
                record[i * 10][0] = record[i][0]
                record[i * 10][1] = True
        except:
            pass
    print record[k][0] + 1
else:
    print [0, 1, 1, 3, 1, 1, 3, 2, 1, 9][k]

Submission status: Wrong Answer

Solution code:
K = int(input())

while K%2 == 0:
    K //= 2
while K%5 == 0:
    K //= 5
ans = 40
for i in range(1, 100001):
    ans = min(ans, sum(map(int, str(K*i))))
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

while K%2 == 0:
    K //= 2
while K%5 == 0:
    K //= 5
print(sum(map(int, str(K))))

Submission status: Wrong Answer

Solution code:
""" small multiple """

K = int(input())

def get_sum_each_digits(number):
    """
    get sum.
    """
    chars = list(str(number))
    int_map = map(int, chars)
    result = sum(int_map)
    # print("number:{0}, result:{1}".format(number, result))
    return result

def main():
    """
    main function.
    """

    min = K
    multiple = 0
    while multiple < 100000:
        multiple += 1
        temp = get_sum_each_digits(K * multiple)
        if temp < min:
            min = temp
        if min == 1:
            break

    # print("ans ---")
    print(min)

main()

Submission status: Wrong Answer

Solution code:
""" small multiple """

K = int(input())

def get_sum_each_digits(number):
    """
    get sum.
    """
    chars = list(str(number))
    int_map = map(int, chars)
    result = sum(int_map)
    # print("number:{0}, result:{1}".format(number, result))
    return result

def main():
    """
    main function.
    """

    min = K
    multiple = 0
    while multiple < 10:
        multiple += 1
        temp = get_sum_each_digits(K * multiple)
        if temp < min:
            min = temp
        if min == 1:
            break

    # print("ans ---")
    print(min)

main()

Submission status: Wrong Answer

Solution code:
""" small multiple """

K = int(input())

def get_sum_each_digits(number):
    """
    get sum.
    """
    chars = list(str(number))
    int_map = map(int, chars)
    result = sum(int_map)
    # print("number:{0}, result:{1}".format(number, result))
    return result

def main():
    """
    main function.
    """

    min = K
    multiple = 0
    while multiple < 10000:
        multiple += 1
        temp = get_sum_each_digits(K * multiple)
        if temp < min:
            min = temp

    # print("ans ---")
    print(min)

main()

Submission status: Wrong Answer

Solution code:
def solve():
    n = input()
    ans = sum([int(b) for b in str(n)])
    while True:
        sign = False
        for x in xrange(1, 10):
            if x * n % 10 == 0:
                n = n * x / 10
                sign = True
                break
        if sign:
            continue
        else:
            print min(sum([int(a) for a in str(n)]), ans)
            break
solve()

Submission status: Wrong Answer

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

import numpy as np

if __name__ == "__main__":
    K = int(raw_input())
    graph = np.ones(K, int) * K
    graph[1] = 0
    visited = np.zeros(K, int)

    queue = []
    visited[1] = 1
    queue.append(1)
    while graph[0] == K:
        tmp = queue[0]
        queue = queue[1:]

        target1 = (tmp + 1) % K
        graph[target1] = min(graph[target1], graph[tmp] + 1)
        if visited[target1] == 0:
            visited[target1] = 1
            queue.append(target1)

        target2 = (tmp * 10) % K
        graph[target2] = min(graph[target2], graph[tmp])
        if visited[target2] == 0:
            visited[target2] = 1
            queue.append(target2)


    print int(graph[0] + 1)

Submission status: Wrong Answer

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

import numpy as np

if __name__ == "__main__":
    K = int(raw_input())
    hoge = np.ones(K, int) * K
    hoge[1] = 0
    visited = np.zeros(K, int)

    stock = [1]
    visited[1] = 1
    while hoge[0] == K:
        tmp = stock.pop()

        target1 = (tmp + 1) % K
        hoge[target1] = min(hoge[target1], hoge[tmp] + 1)
        if visited[target1] == 0:
            stock.append(target1)
            visited[target1] = 1

        target2 = (tmp * 10) % K
        hoge[target2] = min(hoge[target2], hoge[tmp])
        if visited[target2] == 0:
            stock.append(target2)
            visited[target2] = 1

    print int(hoge[0] + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
list1 = []
for i in range(1,10*n):
    s = str(n*i)
    list1.append(sum(list(map(lambda x:int(x),s))))
print(min(list1))

Submission status: Wrong Answer

Solution code:
n = int(input())
list1 = []
for i in range(1,n):
    s = str(n*i)
    list1.append(sum(list(map(lambda x:int(x),s))))
print(min(list1))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque

INF = float('inf')
K = int(input())
G = defaultdict(list)

for v in range(K):
    G[v].append((0, (v * 10) % K))
    G[v].append((1, (v + 1) % K))

def zero_one_bfs_shortest_path(s):
    d = [INF] * K
    d[s] = 0
    dq = deque()
    dq.appendleft(s)
    while len(dq) != 0:
        u = dq.popleft()
        for w, v in G[u]:
            if d[v] != INF:continue
            d[v] = d[u] + w
            if w == 0: dq.appendleft(v)
            else: dq.append(v)
    return d

print(zero_one_bfs_shortest_path(1)[0] + 1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque

INF = float('inf')
K = int(input())
G = defaultdict(list)

for v in range(1, K):
    G[v].append((0, (v * 10) % K))
    G[v].append((1, (v + 1) % K))

def zero_one_bfs_shortest_path(s):
    d = [INF] * K
    d[s] = 0
    dq = deque()
    dq.appendleft(s)
    while len(dq) != 0:
        u = dq.popleft()
        for w, v in G[u]:
            if d[v] != INF or d[v] < d[u] + w:continue
            d[v] = d[u] + w
            if w == 0: dq.appendleft(v)
            else: dq.append(v)
    return d

print(zero_one_bfs_shortest_path(1)[0] + 1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque

INF = float('inf')
K = int(input())
G = defaultdict(list)

for v in range(1, K):
    G[v].append((0, (v * 10) % K))
    G[v].append((1, (v + 1) % K))

def zero_one_bfs_shortest_path(s):
    d = [INF] * K
    d[s] = 0
    dq = deque()
    dq.appendleft(s)
    while len(dq) != 0:
        u = dq.popleft()
        for w, v in G[u]:
            if d[v] != INF:continue
            d[v] = d[u] + w
            if w == 0: dq.appendleft(v)
            else: dq.append(v)
    return d

print(zero_one_bfs_shortest_path(1)[0] + 1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque

INF = float('inf')
K = int(input())
G = defaultdict(list)

for v in range(1, K + 1):
    G[v].append((0, (v * 10) % K))
    G[v].append((1, (v + 1) % K))

def zero_one_bfs_shortest_path(s):
    d = [INF] * K
    d[s] = 0
    dq = deque()
    dq.appendleft(s)
    while len(dq) != 0:
        u = dq.popleft()
        for w, v in G[u]:
            if d[v] != INF:continue
            d[v] = d[u] + w
            if w == 0: dq.appendleft(v)
            else: dq.append(v)
    return d

print(zero_one_bfs_shortest_path(1)[0] + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
ans=len(str(K))*9
for i in range(1,5*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 math
K = int(input())
ans = 9*5
for i in range(1,K):
	n = K*i
	s = 0
	while n > 0:
		s += n % 10
		n = math.floor(n/10)
	if s < ans:
		ans = s
print(ans)

Submission status: Wrong Answer

Solution code:
import math
K = int(input())
ans = 9*5
for i in range(1,10):
	n = K*i
	s = 0
	while n > 0:
		s += n % 10
		n = math.floor(n/10)
	if s < ans:
		ans = s
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def small_multiple(K):
    n_digits = int(math.log10(float(K))) + 1
    min_val = K
    min_K = K
    for i in range(int(10**(n_digits+1))):
        K_m = K*(i+1)
        K_m_n_digits = int(math.log10(float(K_m))) + 1
        val = 0
        for j in range(K_m_n_digits):
            val += (K_m % (10**(j+1))) // (10**j)
        if val < min_val:
            min_val = val
            min_K = K_m
    return min_val

if __name__ == "__main__":
    # raw_input()
    # nums = [int(i) for i in raw_input().split()]
    # print(" ".join([str(num) for num in reverse_append(nums)]))
    # run_test(small_multiple, test_pair)
    K = int(input())
    print(small_multiple(K))

Submission status: Wrong Answer

Solution code:
import math

def small_multiple(K):
    n_digits = int(math.log10(float(K))) + 1
    min_val = K
    for i in range(int(10**n_digits)):
        K_m = K*(i+1)
        K_m_n_digits = int(math.log10(float(K_m))) + 1
        val = 0
        for j in range(K_m_n_digits):
            val += (K_m % (10**(j+1))) // (10**j)
        if val < min_val:
            min_val = val
    return min_val

if __name__ == "__main__":
    # raw_input()
    # nums = [int(i) for i in raw_input().split()]
    # print(" ".join([str(num) for num in reverse_append(nums)]))
    # run_test(small_multiple, test_pair)
    K = int(input())
    print(small_multiple(K))
# ===

Submission status: Wrong Answer

Solution code:

import math

def small_multiple(K):
    n_digits = int(math.log10(float(K))) + 1
    min_val = K
    for i in range(int(10**n_digits)):
        K_m = K*(i+1)
        K_m_n_digits = int(math.log10(float(K_m))) + 1
        val = 0
        for j in range(K_m_n_digits):
            val += (K_m % (10**(j+1))) // (10**j)
        if val < min_val:
            min_val = val
    return min_val

if __name__ == "__main__":
    # raw_input()
    # nums = [int(i) for i in raw_input().split()]
    # print(" ".join([str(num) for num in reverse_append(nums)]))
    # run_test(small_multiple, test_pair)
    K = int(input())
    print(small_multiple(K))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from heapq import heappush, heappop
INF = float("inf")


def main():
    K = int(input())
    graph = defaultdict(list)
    for i in range(K):
        graph[i].append((1, (i + 1) % K))
        graph[i].append((0, (i * 10) % K))

    cost = [None] * K
    cost[1] = 1
    que = deque()
    que.appendleft(1)
    while len(que) != 0:
        now = que.popleft()

        for c, node in graph[now]:
            if cost[node] is None:
                cost[node] = cost[now] + c
                if c == 0:
                    que.appendleft(node)
                else:
                    que.append(node)

    print(cost[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from heapq import heappush, heappop
INF = float("inf")


def main():
    K = int(input())
    graph = defaultdict(list)
    for i in range(K):
        graph[i].append((1, (i + 1) % K))
        graph[i].append((0, (i * 10) % K))

    h = []
    cost = [None] * K
    cost[1] = 0
    heappush(h, (0, 1))
    while len(h) != 0:
        _, node = heappop(h)

        for c, n in graph[node]:
            if cost[n] is None:
                cost[n] = cost[node] + c
                heappush(h, (c, n))
    print(cost[0] + 1)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
dist = [0] * n
dist[1] = 1
d = collections.deque()
d.append(1)


def ans():
    while True:
        u = d.popleft()
        if (u * 10) % n == 0:
            return dist[u]
        if (u + 1) % n == 0:
            return dist[u] + 1
        if dist[(u + 1) % n] == 0:
            dist[(u + 1) % n] = dist[u] + 1
            d.append((u + 1) % n)
        if dist[(u * 10) % n] == 0:
            dist[(u * 10) % n] = dist[u]
            d.appendleft((u * 10) % n)

print(ans())

Submission status: Wrong Answer

Solution code:
K=int(input())
a=list(str(K))

ans=sum(list(map(int,a)))

for i in range(1,99999):
    a=list(str(K*i))
    a2=list(map(int,a))

    ans=min(ans,sum(a2))

print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
a=list(str(K))

ans=sum(list(map(int,a)))

for i in range(1,K):
    a=list(str(K*i))
    a2=list(map(int,a))

    ans=min(ans,sum(a2))

print(ans)

Submission status: Wrong Answer

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

    ans=min(ans,sum(a2))

print(ans)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(500000):
    a = keta_sum( k * (i+2) )
    if a not in n_list:
        n_list.append( a )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [100000000]
X = int(10000000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    else:
        Y = str(N*i)
        a_list = list(map(int,Y))
        ddd = sum(a_list)
        if ddd < array[0]:
            array.pop(0)
            array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [100000000]
X = int(100000000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    else:
        Y = str(N*i)
        a_list = list(map(int,Y))
        ddd = sum(a_list)
        if ddd < array[0]:
            array.pop(0)
            array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [10000000000000]
X = int(1000000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    else:
        Y = str(N*i)
        a_list = list(map(int,Y))
        ddd = sum(a_list)
        if ddd < array[0]:
            array.pop(0)
            array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [10000000000000]
X = int(100000/N)
     
for i in range(X+1):
    if i == 0:
        i +=1
    else:
        Y = str(N*i)
        a_list = list(map(int,Y))
        ddd = sum(a_list)
        if ddd < array[0]:
            array.pop(0)
            array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [10000000000000]
X = int(100000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    else:
        Y = str(N*i)
        a_list = list(map(int,Y))
        ddd = sum(a_list)
        if ddd < array[0]:
            array.pop(0)
            array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [10000000000000]
X = int(100000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    Y = str(N*i)
    a_list = list(map(int,Y))
    ddd = sum(a_list)
    if ddd < array[0]:
        array.pop(0)
        array.append(ddd)

print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [1000000]
X = int(100000/N)
     
for i in range(X):
    if i == 0:
        i +=1
    Y = str(N*i)
    a_list = list(map(int,Y))
    ddd = sum(a_list)
    if ddd < array[0]:
        array.pop(0)
        array.append(ddd)
    
        
print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [1000000]
X = int(100000/N)
     
for i in range(X):
    Y = str(N*(i+1))
    a_list = list(map(int,Y))
    ddd = sum(a_list)
    if ddd < array[0]:
        array.pop(0)
        array.append(ddd)
    
        
print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = [10000]
X = int(100000/N)
     
for i in range(X):
    Y = str(N*(i+1))
    a_list = list(map(int,Y))
    ddd = sum(a_list)
    if ddd < array[0]:
        array.pop(0)
        array.append(ddd)
    
        
print(int(array[0]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = str(N*(i+1))
    a_list = list(map(int,Y))
    ddd = sum(a_list)
    array.append(ddd)
        
print(int(min(array)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = str(N*(i+1))
    a_list = list(map(float,Y))
    ddd = sum(a_list)
    array.append(ddd)
        
print(int(min(array)))

Submission status: Wrong Answer

Solution code:
import time

start = time.clock()
K = int(input())
minSum = 1000000
for i in range(1, 1000000):
    num = K * i
    numSum = sum(list(map(int,str(num))))
    if minSum > numSum:
        minSum = numSum
    if i % 5 == 0:
        current = time.clock()
        if current - start > 1.9:
            break
print(minSum)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = N*(i+1)
    STR = str(Y)
    a_list = list(map(float,STR))
    ddd = sum(a_list)
    array.append(ddd)
        
print(int(min(array)))

Submission status: Wrong Answer

Solution code:
import math
K=int(input())
def f(x):
  return sum(map(int,list(str(x))))
ans=f(K)
for i in range(2,10**int(math.log10(K))+1):
    if f(K*i)<ans:
        ans = f(K*i)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = N*(i+1)
    STR = str(Y)
    a_list = list(map(float,STR))
    array.append(sum(a_list))
        
print(int(min(array)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = N*(i+1)
    STR = str(Y)
    a_list = list(map(float,STR))
    array.append(sum(a_list))
        
sum_list = min(array)
print(int(sum_list))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

# AtCoder Beginner Contest 077
# D - Small Multiple

from sys import stdin

def sumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n %  10
        n    = n // 10
    return sum

def solve(K):
    minSum = sumOfDigits(K)
    for i in range(2, 1000000):
        minSum = min(minSum, sumOfDigits(K * i))
    return minSum

K = int(stdin.readline())
print(solve(K))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from sys import stdin, stdout
from bisect import bisect
def rint():
   return map(int, stdin.readline().split())

K = int(input())

ans = 10**100
for i in range(1,10**3):
   tmp = K*i
   tmps = str(tmp)
   tmp = 0
   for kk in tmps:
      tmp += int(kk)
   ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
minSum=54
for i in range(1,10):
    tmp=0
    for j in str(K*i):
        tmp+=int(j)
    minSum=min(tmp,minSum)
print(minSum)

Submission status: Wrong Answer

Solution code:
def s(n):
    ret = 0
    sn = str(n)
    for c in sn:
        ret += int(c)
    return ret

N = int(input())
t = N

ans = s(N)
for i in range(600000):
    t += N
    ans = min(s(t), ans)

print(ans)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(300000):
    a = keta_sum( k * (i+2) )
    if a not in n_list:
        n_list.append( a )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)
     
for i in range(X):
    Y = N*(i+1)
    STR = str(Y)
    a_list = list(map(float,STR))
    sum_list = sum(a_list)
    array.append(sum_list)
        

print(int(min(a_list)))

Submission status: Wrong Answer

Solution code:
def s(n):
    ret = 0
    sn = str(n)
    for c in sn:
        ret += int(c)
    return ret

N = int(input())
t = N

ans = float('inf')
for i in range(600000):
    t += N
    ans = min(s(t), ans)

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    ans = 50
    for i in range(1,10000):
        tmp = N * i
        cand = tmp%10
        while tmp > 0:
            tmp = tmp // 10
            cand += tmp%10
        if cand < ans:
            ans = cand
    print(ans)

solve()

Submission status: Wrong Answer

Solution code:
K=int(input())
def f(x):
  return sum(map(int,list(str(x))))
ans=f(K)
for i in range(2,2*K+1):
    if f(K*i)<ans:
        ans = f(K*i)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(1,1000):
	a.append(sum(map(int,str(n*i))))
print(min(a))

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    ans = 50
    for i in range(1,10):
        tmp = N * i
        cand = tmp%10
        while tmp > 0:
            tmp = tmp // 10
            cand += tmp%10
        if cand < ans:
            ans = cand
    print(ans)

solve()

Submission status: Wrong Answer

Solution code:
def main():
    """K の正の倍数の 10 進法での各桁の和としてありうる最小の値を求めてください。

    2 ≤ K ≤ 10^5

    min: 1が1つと他が0 -> 10^n, e.g.: 5*2, 25*4
    10倍しても元のKと和は変わらない
    1-9倍とは限らない?: 入力例 2　11111=41×271, 4+1=5では？
    """
    K = int(input())

    ans = sum_digits(K)
    for i in range(2, 10):
        ans = min(ans, sum_digits(K * i))

    print(ans)


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
array = []
X = int(100000/N)

for i in range(X):
    Y = N*(i+1)
    STR = str(Y)
    a_list = list(map(float,STR))
    sum_list = sum(a_list)
    array.append(sum_list)
    
min_list = min(array)
print(int(min_list))

Submission status: Wrong Answer

Solution code:
import time
import sys
import math

start = time.clock()
K = int(input())
minSum = 10000
for i in range(1, 1000000):
    num = K * i
    numSum = sum(list(map(int,str(num))))
    if minSum > numSum:
        minSum = numSum
    if i % 5 == 0:
        current = time.clock()
        if current - start > 1.8:
            break
print(minSum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import time
import sys
import math

start = time.clock()
K = int(input())
minSum = 10000
for i in range(1, 1000000):
    num = K * i
    numSum = sum(list(map(int,str(num))))
    if minSum > numSum:
        minSum = numSum
    if i % 100 == 0:
        current = time.clock()
        if current - start > 1.8:
            break
print(minSum)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(1, 10000):
    v = 0
    for s in str(N*i):
        v = v + int(s)
    l.append(v)
print(min(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
a = 2
print(min(sum([int(s) for s in str(a * K)]) for i in range(K)))

Submission status: Wrong Answer

Solution code:
print(2)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

# AtCoder Beginner Contest 077
# D - Small Multiple

from sys import stdin

def sumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n %  10
        n    = n // 10
    return sum

def solve(K):
    minSum = sumOfDigits(K)
    for i in range(2, 100001):
        minSum = min(minSum, sumOfDigits(K * i))
    return minSum

K = int(stdin.readline())
print(solve(K))

Submission status: Wrong Answer

Solution code:
K=int(input())
def f(x):
  return sum(map(int,list(str(x))))
ans=f(K)
for i in range(2,K+1):
    if f(K*i)<ans:
        ans = f(K*i)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

K = int(input())
minSum = 10000
for i in range(1, 10000):
    num = K * i
    numSum = sum(list(map(int,str(num))))
    if minSum > numSum:
        minSum = numSum
print(minSum)

Submission status: Wrong Answer

Solution code:
import numpy as np

k= int(input())

temp = sum(np.array(list(map(int,list(str(k))))))
count = 1
while(temp>int(np.log10(k*count)) and count < 10):
    temp = min(temp,sum(np.array(list(map(int,list(str(k*count)))))))
    #print(count,temp,(np.array(list(map(int,list(str(k*count)))))),sum((np.array(list(map(int,list(str(k*count))))))))
    count += 1
print(temp)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(100000):
    a = keta_sum( k * (i+2) )
    if a not in n_list:
        n_list.append( a )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
import sys
import math

K = int(input())
minSum = 10000
for i in range(1, 100):
    num = K * i
    numSum = sum(list(map(int,str(num))))
    if minSum > numSum:
        minSum = numSum
print(minSum)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(300000):
    n_list.append( keta_sum( k * (i+1) ) )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
k = int(input())

mins = float('inf')
for i in range(300000):
    b = k * (i + 1)
    s = 0
    for j in str(b):
        s += int(j)
    if mins > s:
        mins = s
    
print(mins)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(100000):
    n_list.append( keta_sum( k * (i+1) ) )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy as cp
import math
# data の桁数を取得する
def getSize(data) : return int (math.log10(data) + 1)

K = int(input())
MIN = float("Inf")
dig = getSize(K)
i = 2
while dig <= MIN : 
    dig = getSize(K)
    l = [int(x) for x in list(str(K))]
    s = sum(l)
    if s < MIN : MIN = s
    K = K * i
    i += 1

print(MIN)

Submission status: Wrong Answer

Solution code:
#http://abc077.contest.atcoder.jp/
# -*- coding: utf-8 -*-

k = int(input())

def keta_sum(n):
    l = [int(x) for x in list(str(n))]
    return sum(l)

n_list = []
for i in range(100):
    n_list.append( keta_sum( k * (i+1) ) )

print( min(n_list) )

Submission status: Wrong Answer

Solution code:
k = int(input())

mins = float('inf')
for i in range(200000):
    b = k * (i + 1)
    s = 0
    for j in str(b):
        s += int(j)
    if mins > s:
        mins = s
    
print(mins)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
ll = []
for i in range(1, 10):
    l.append(str(N*i))
for s in l:
    v = 0
    for i in s:
        v = v + int(i)
    ll.append(v)
print(min(ll))

Submission status: Wrong Answer

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

def sum_of_each_level(number):
    lev_list = [int(i) for i in str(number)]
    return sum(lev_list)

def calc_level_num(number):
    return len(str(number))

def main():
    K = int(input())
    com_num = K
    i = 1
    while sum_of_each_level(com_num) < calc_level_num(com_num):
        com_num = K * i
        i += 1
    return sum_of_each_level(com_num)

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_b

"""
import sys
from sys import stdin
input = stdin.readline


def calc_sum(n):
    t = [int(x) for x in list(str(n))]
    result = sum(t)
    return result


def main(args):
    K = int(input())
    ans = calc_sum(K)

    for i in range(2, 100000):
        res = calc_sum(K * i)
        ans = min(ans, res)
    print(ans)



if __name__ == '__main__':
    main(sys.argv[1:])