题目:

python for 小数步长 python循环步长为小数_循环节


代码:

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)}")