赞
踩
题目:
代码:
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
p, q = map(int, input().split())
num = int(input())
m, n = p - 1, q - p + 1 #m为非循环部分的长度 n为循环部分的长度
k = int(num / (10 ** n))#k非循环节 l循环节
l = int(num % (10 ** n))
x, y = k * (10 ** n - 1) + l, (10 ** n - 1) * (10 ** m)
g = gcd(x, y)
x, y = x / g, y / g
print(f"{int(x)} {int(y)}")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。