循环小数【决赛】【研究生组】(python)

循环小数【决赛】【研究生组】(python),第1张

代码:

详细分析见精准表达浮点数 (python

import math
p, q = map(int,input().split())
a = input()
b = a[p-1:q]
a, b = int(a), int(b)
subnums, momnums = (10**(q-p+1)-1)*a + b, (10**q)*(10**(q-p+1)-1)
print(int(subnums/math.gcd(subnums,momnums)), int(momnums/(math.gcd(subnums,momnums))))

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/883478.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-14
下一篇2022-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存