Problem:


小数位の和

a, b, n は、いずれも正の整数であるとします。分数 a / b の小数第 i 位の数を f(i) とします (0 ≤ f(i) ≤ 9)。このとき、i = 1 から n までの f(i) の和を s とします。

s = f(1) + f(2) + ... + f(n)

a, b, n を読み込んで、 s を出力して終了するプログラムを作成してください。

Input

入力は複数のデータセットからなります。各データセットとして、3 つの整数 a (1 ≤ a ≤ 1000), b (1 ≤ b ≤ 10000), n (1 ≤ n ≤ 100) が空白区切りで１行に与えられます。

データセットの数は 100 を超えません。

Output

データセットごとに、s を１行に出力します。

Sample Input

1 2 3
2 3 4
5 4 3
4 3 2

Output for the Sample Input

5
24
7
6



Sample input:
1 2 3
2 3 4
5 4 3
4 3 2


Sample output:
5
24
7
6

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    a, b, n = (int(s) for s in line.split())
    result = 0
    for i in xrange(1, n+1):
        result += (a * (10 ** i) // b) % 10
    print(result)

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
    a, b, n = map(int, s.split())
    print sum(map(int, str(a*1.0 / b).ljust(9,'0').split('.')[1][0:n]))

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    a,b,n=map(int,s.split())
    a=a%b
    s=0
    for i in range(n):
        a*=10
        s+=a/b
        a%=b
    print s

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin:
    a,b,n=map(int,s.split())
    s=0
    while n:
        a=a%b*10
        s+=a/b
        n-=1
    print s

Submission status: Accepted

Solution code:
while True:
    try:
        a,b,n = map(int, raw_input().split())
        s = 0
        for i in range(n):
            a = a%b*10
            s += a/b
        print s
    except:
        break

Submission status: Accepted

Solution code:
try:
    while True:
        a, b, n = map(int, raw_input().split())
        print sum(map(int, str(a * 10 ** n / b)[-n:]))
except EOFError:
    pass

Submission status: Accepted

Solution code:
while 1:
    try:
        a, b, n = map(int, raw_input().split())
    except EOFError:
        break
    a %= b
    ret = 0
    for i in xrange(n):
        a *= 10
        ret += a / b
        a %= b
    print ret

Submission status: Accepted

Solution code:
while True:
    try:
        s = input()
    except EOFError:
        break

    a, b, n = map(int, s.split())
    a %= b
    x = 0
    for i in range(n):
        a *= 10
        if a >= b:
            q, a = divmod(a, b)
            x += q
    print(x)

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        a, b, n = map(int, line.split())
        a %= b
        res = 0
        for i in range(n):
            d, a = divmod(10*a, b)
            res += d
        write("%d\n" % res)
solve()

Submission status: Accepted

Solution code:
while True:
    try:
        a,b,n=map(int, input().split())
    except:
        break
    a=a%b
    total=0
    for i in range(n):
        if a==0:
            break
        a=a*10
        total+=int(a/b)
        a=(a%b)
    print(total)

Submission status: Accepted

Solution code:

while True:
    try:
        a, b, n = [int(x) for x in input().split()]
    except:
        break
    ans = 0
    a%=b
    for i in range(n):
        a *=10
        ans += a//b
        a %=b
    print(ans)

Submission status: Accepted

Solution code:
while True:
  try:
    a,b,n=map(int,input().split())
    ans = 0
    for i in range(n):
      a*=10
      ans+=(a//b)%10
    print(ans)
  except EOFError:
    break

Submission status: Accepted

Solution code:
while 1:
    try:
        ans=0
        a,b,n=map(int,input().split())
        a=a%b
        for i in range(n):
            a *=10
            ans +=a//b
            a=a%b
        print(ans)
    except:break

Submission status: Accepted

Solution code:
while 1:
    try:
        a,b,n=map(int,input().split())
        ans=0
        a=a%b
        for i in range(n):
            if a==0:break
            a*=10
            ans+=a//b
            a=a%b
        print(ans)
    except:break

Submission status: Accepted

Solution code:
while(1):
    try:
        a,b,n = [int(i) for i in input().split()]
        num = "{float_:.{length}f}".format(float_=a/b, length=n+1)
        decimal = [int(i) for i in num.split(".")[1]]
        print(sum(decimal[:n]))
    except EOFError:
        break

Submission status: Accepted

Solution code:
while True:
    try: x = input()
    except: break
    
    a, b, n = map(int, x.split())
    s = 0
    for _ in range(n):
        a *= 10
        s += (a // b) % 10
    print(s)

Submission status: Accepted

Solution code:
while(True):
    try: a,b,n = map(int, input().split())
    except: break
    print(sum(a*10**i//b%10 for i in range(1,n+1)))

Submission status: Accepted

Solution code:
import sys
for l in sys.stdin:
    a,b,n=map(int,l.split(" "))
    print(sum(map(int,list(str((a%b)*10**n//b)))))

Submission status: Runtime Error

Solution code:
sum(map(int, format(input()/float(input()), ".11f").split(".")[1])[:input()])

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b, n = map(int, input().split())
    except:
        break

    sum = 0
    s = list(str(a/b))
    for i in s[2:2+n]:
        sum += int(i)

    print(sum)

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b, n = map(int, input().split())
        s = list(str(a/b))
    except:
        break

    sum = 0
    for i in s[2:2+n]:
        sum += int(i)

    print(sum)

Submission status: Runtime Error

Solution code:
while True:
    try:
        a, b, n = map(int, input().split())
    except:
        break

    s = str(a/b)
    sum = 0
    for i in s[2:2+n]:
        sum += int(i)

    print(sum)

Submission status: Runtime Error

Solution code:
def f(num, i, tmp):
    for k in xrange(10):
        if k * 10**(-i) <= num - tmp < (k + 1) * 10**(-i):
            return k
            break

while True:
    try:
        a,b,n = map(int,raw_input().split())
    except EOFError:
        break
    
    a = float(a)
    s = 0
    tmp = f(a/b,0,0) 
    for i in range(1,n+1):
        val = f(a/b, i, tmp)
        s += val
        tmp += float(val * 10 ** (-i))
    print s

Submission status: Runtime Error

Solution code:
 -*- coding: utf-8 -*-
def f(num, i, tmp):
    for k in xrange(10):
        if k * 10**(-i) <= num - tmp < (k + 1) * 10**(-i):
            return k
            break

while True:
    try:
        a,b,n = map(int,raw_input().split())
    except EOFError:
        break
    
    a = float(a)
    s = 0
    tmp = f(a/b,0,0) 
    for i in range(1,n+1):
        val = f(a/b, i, tmp)
        s += val
        tmp += float(val * 10 ** (-i))
    print s

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def f(num, i, tmp):
    for k in xrange(10):
        if k * 10**(-i) <= num - tmp < (k + 1) * 10**(-i):
            return k
            break

while True:
    try:
        a,b,n = map(int,raw_input().split())
    except EOFError:
        break
    
    a = float(a)
    s = 0
    tmp = f(a/b,0,0) 
    for i in range(1,n+1):
        val = f(a/b, i, tmp)
        s += val
        tmp += float(val * 10 ** (-i))
    print s

Submission status: Runtime Error

Solution code:

def f(num, i, tmp):
    for k in xrange(10):
        if k * 10**(-i) <= num - tmp < (k + 1) * 10**(-i):
            return k
            break

while True:
    
    a,b,n = map(int,raw_input().split())

    
    a = float(a)
    s = 0
    tmp = f(a/b,0,0) 
    for i in range(1,n+1):
        val = f(a/b, i, tmp)
        s += val
        tmp += float(val * 10 ** (-i))
    print s

Submission status: Runtime Error

Solution code:

while (1):
	ls = raw_input()
	ls = ls.split()

	st = str(float(ls[0]) / float(ls[1]))
	print st
	s = 0
	for i in st[2:int(ls[2]) + 2]:
		s += int(i)

	print s

Submission status: Runtime Error

Solution code:

while 1:
	try:
		ls = raw_input()
	except:
		break
	else:
		ls = ls.split()
	
		st = str(float(ls[0]) / float(ls[1]))
		print st
		s = 0
		for i in st[2:int(ls[2]) + 2]:
			s += int(i)

		print s

Submission status: Runtime Error

Solution code:

while 1:
	try:
		ls = raw_input()
	except:
		exit()
	else:
		ls = ls.split()
	
		st = str(float(ls[0]) / float(ls[1]))
		print st
		s = 0
		for i in st[2:int(ls[2]) + 2]:
			s += int(i)

		print s

Submission status: Runtime Error

Solution code:
while 1:
	try:
		ls = raw_input()
		ls = ls.split()
	
		st = str(float(ls[0]) / float(ls[1]))
		s = 0
		for i in st[2:int(ls[2]) + 2]:
			s += int(i)

		print s
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
while 1:
	try:
		ls = raw_input()
	except EOFError:
		break

	ls = ls.split()
	st = str(float(ls[0]) / float(ls[1]))
	s = 0
	for i in st[2:int(ls[2]) + 2]:
		s += int(i)
	print st

Submission status: Runtime Error

Solution code:
while True:
	try:
		num = raw_input().split(" ")
		sum = 0
		x = float(num[0]) / float(num[1])
		if x < 1:
			x = x + 1.0
		for var in range(1, int(num[2]) + 1):
			sum += int(str(x * 10**var)[var:var+1])
			
		print sum
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
while True:
		num = raw_input().split(" ")
		sum = 0
		x = float(num[0]) / float(num[1])
		if x < 1:
			x = x + 1.0
		for var in range(1, int(num[2]) + 1):
			sum += int(str(x * 10**var)[var:var+1])
			
		print sum

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin:
	a,b,n=map(int,line.split())
	for i in range(n):a*=10
	s=str(a//b)[::-1]
	cnt=0
	for i in range(n):cnt+=int(s[i])
	print(cnt)

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin:
	a,b,n=map(int,line.split())
	for i in range(n):a*=10
	s=str(int(a/b))[::-1]
	cnt=0
	for i in range(n):cnt+=int(s[i])
	print(cnt)

Submission status: Runtime Error

Solution code:
import sys
inp=[]
for line in sys.stdin:
	inp.append(line)
for line in inp:
	a,b,n=map(int,line.split())
	for i in range(n):a*=10
	s=str(int(a/b))[::-1]
	cnt=0
	for i in range(n):cnt+=int(s[i])
	print(cnt)

Submission status: Runtime Error

Solution code:
import sys
inp=[]
for line in sys.stdin:
	if line:inp.append(line)
for line in inp:
	a,b,n=map(int,line.split())
	for i in range(n):a*=10
	s=str(int(a/b))[::-1]
	cnt=0
	for i in range(n):cnt+=int(s[i])
	print(cnt)

Submission status: Runtime Error

Solution code:
import sys
for e in sys.stdin:
 a,b,n=map(int,e.split())
 print(sum(int(i)for i in str(a/b)[2:][:n]))

Submission status: Runtime Error

Solution code:
import sys
import math as m
ans = []
for line in sys.stdin:
    oneset = list(map(int,input().split()))
    sums = 0
    for i in range(oneset[2]):
        k = int(m.floor((oneset[0] / oneset[1] ) * (10 ** k)))
        sums = sums + (int % 10)
    ans.append(sums)
    
for i in range(len(ans)):
    print(ans[i])

Submission status: Runtime Error

Solution code:
import sys
import math as m
ans = []
for line in sys.stdin:
    try:
        oneset = list(map(int,line.split()))
        sums = 0
        for i in range(oneset[2]):
            k = int(m.floor((oneset[0] / oneset[1] ) * (10 ** (i + 1))))
            sums = sums + (k % 10)
        ans.append(sums)
    except:
        break
for i in range(len(ans)):
    print(strint((ans[i])))

Submission status: Runtime Error

Solution code:
import sys
import math as m
ans = []
for line in sys.stdin: 
    oneset = list(map(int,input().split()))
    sums = 0
    for i in range(oneset[2]):
        k = int(m.floor((oneset[0] * (10 ** (i + 1)/ oneset[1] ) ))
        sums = sums + (k % 10)
    ans.append(sums)
    print(sums)

Submission status: Runtime Error

Solution code:
import sys
import itertools

for s in sys.stdin:
	input = int(s)
	cnt = 0
	for i in itertools.product(range(10), repeat=4):
		if sum(i) == input:
			cnt += 1
	print cnt

Submission status: Runtime Error

Solution code:
import sys

#getInt = lambda x, a : int((x % 10 ** a - x % 10 ** (a - 1))/10**(a-1))
getNum = lambda x, a : int(x / 10 ** a % 10)

for str in iter(sys.stdin.readline, ""):
        str.split()

        firstnum  = float(str[0])
        secondnum = float(str[2])
        therdnum  = int(str[4])

        ans = sum([getNum(firstnum/secondnum, -x) for x in range(1, therdnum+1)])

print ans

Submission status: Runtime Error

Solution code:
import sys

#getInt = lambda x, a : int((x % 10 ** a - x % 10 ** (a - 1))/10**(a-1))
getNum = lambda x, a : int(x / 10 ** a % 10)

for str in iter(sys.stdin.readline, ""):
        str.split()

        firstnum  = float(str[0])
        secondnum = float(str[2])
        therdnum  = int(str[4])

        ans = sum([getNum(firstnum/secondnum, -x) for x in range(1, therdnum+1)])
        print ans

Submission status: Runtime Error

Solution code:
import sys

#getInt = lambda x, a : int((x % 10 ** a - x % 10 ** (a - 1))/10**(a-1))
getNum = lambda x, a : int(x / 10 ** a % 10)

for str in sys.stdin:
        str.split()

        firstnum  = float(str[0])
        secondnum = float(str[2])
        therdnum  = int(str[4])

        ans = sum([getNum(firstnum/secondnum, -x) for x in range(1, therdnum+1)])
        print ans

Submission status: Runtime Error

Solution code:
s in sys.stdin:
    a,b,n=map(int,s.split())
    a=a%b
    s=0
    for i in range(n):
        a*=10
        s+=a/b
        a%=b
    print s

Submission status: Runtime Error

Solution code:
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

while True:
    n = int(raw_input())
    if not n:
        break
    i, num, sum = 0, 1, 0
    while num < n:
        if p[i] == 1:
            num += 1
            sum += i
        i += 1
    print sum