while True:
try:
from decimal import Decimal,getcontext
getcontext().prec=1010
a,b,n=map(int,input().split())
m=str(input())
s=Decimal(a)/Decimal(b)
s=str(s)
s=list(s)
y=0
for x in range(len(s)):
if s[x]=='.':
y=1
break
if y==0:
if n==0:
for i in s:
print(i,end='')
print('')
else:
s.append('.')
for w in range(1010):
s.append('0')
for i in range(len(s)):
print(s[i],end='')
if s[i]=='.':
j=i
break
while n>0:
j+=1
print(s[j],end='')
n-=1
print('')
else:
for e in range(len(s)):
if s[e]=='.':
q=e
if len(s)-q<1010:
for w in range(1010-(len(s)-q)):
s.append('0')
if n==0:
if m=='Xiang':
for k in s:
if k=='.':
break
print(k,end='')
print('')
else:
for k in range(len(s)):
if s[k]=='.':
j=k
break
if int(s[j+1])>=5:
s[j-1]=str(int(s[j-1])+1)
for o in s:
if o=='.':
break
print(o,end='')
print('')
else:
if m=='Xiang':
for j in range(len(s)):
print(s[j],end='')
if s[j]=='.':
k=j+1
break
while n>0:
print(s[k],end='')
n-=1
k+=1
print('')
else:
for j in range(len(s)):
print(s[j],end='')
if s[j]=='.':
k=j+1
break
if int(s[k+n])>=5:
s[k+n-1]=str(int(s[k+n-1])+1)
while n>0:
print(s[k],end='')
n-=1
k+=1
print('')
except:
break
全部评论
(1) 回帖