Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gcd(b, d):
- while d and b:
- if d > b:
- d %= b
- else:
- b %= d
- return b + d
- def lcd(b, d):
- bd = b * d
- return bd // gcd(b, d)
- a, b, c, d, N, n = map(int, input().split())
- tA = a
- tC = c
- z = a / b
- x = c / d
- common_denominator = lcd(b, d)
- a *= common_denominator / b
- c *= common_denominator / d
- ans_n = 0
- f = 0
- ans_list = []
- for i in range(1, N + 1):
- t_m1, t_m2 = i, common_denominator
- temp_a = int((a * t_m1) // t_m2)
- temp_c = int((c * t_m1) // t_m2)
- for j in range(temp_a + 1, min(temp_c + 1, N + 1)):
- v = j / i
- if gcd(j, i) == 1 and v != z and v != x:
- ans_n += 1
- ans_list.append([j, i])
- if ans_n == n:
- f = 1
- break
- if f == 1:
- break
- print(ans_n)
- for i in range(ans_n):
- print(*ans_list[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement