SHARE
TWEET

Untitled

a guest Jan 14th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def gcd(a, b):
  2.     while a != 0 and b != 0:
  3.         if a > b:
  4.             a %= b
  5.         else:
  6.             b %= a
  7.     return a+b
  8.  
  9.  
  10. a, b, c, d, N, n = [int(i) for i in input().split()]
  11. l, r = a / b, c / d
  12. e, f = 1, 1
  13. arr = []
  14. num = 0
  15. while len(arr) < n:
  16.     while e <= N and e / f <= l:
  17.         e += 1
  18.     if e / f >= r:
  19.         e = 1
  20.         f += 1
  21.         while f <= N and e / f >= r:
  22.             f += 1
  23.     if e > N or f > N:
  24.         break
  25.     if l < e / f < r:
  26.         if gcd(e, f) == 1:
  27.             arr.append([e, f])
  28.         if e < N:
  29.             e += 1
  30.         else:
  31.             f += 1
  32.             e = 1
  33. print(len(arr))
  34. for i in arr:
  35.     print(i[0], i[1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top