Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import stdin, stdout
- from functools import lru_cache
- input, print = stdin.readline, stdout.write
- @lru_cache(None)
- def check_h(n, w, h, r, cnt_strip):
- hOfRow = h / cnt_strip
- Cnt1 = n // cnt_strip
- Cnt2 = (n - 1) // cnt_strip + 1
- maxW = hOfRow
- minW = hOfRow * r
- if (minW * Cnt1 > w or minW * Cnt2 > w):
- return -1
- if (maxW * Cnt1 < w or maxW * Cnt2 < w):
- return 1
- return 0
- t = int(input())
- ans = []
- for _ in range(0, t):
- my_list = [i for i in input().split()]
- w, h, n, r = int(my_list[0]), int(my_list[1]), int(my_list[2]), float(my_list[3])
- left = 0
- right = n + 1
- if (r == int(r)):
- r = int(r)
- while (right - left > 1):
- m = (left + right) // 2
- res = check_h(n, w, h, r, m)
- if (res == -1):
- left = m
- elif (res == 1):
- right = m
- else:
- left = m
- right = m
- cnt_strip = right
- if (check_h(n, w, h, r, cnt_strip) == 0):
- minCntInRow = n // cnt_strip
- maxCntInRow = (n - 1) // cnt_strip + 1
- ans += [f'{cnt_strip} {minCntInRow} {maxCntInRow}']
- else:
- ans += ['-1']
- print('\n'.join(ans))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement