Debt of Lannister
Tyrion Lannister wants to pay Bronn reward for his services. Being a Lannister, he has an unlimited number of coins of denominations A, and B. He has also got an unlimited number of bags, in which he can give the money. Each bag can contain at most
N rupees. Tyrion wants to pay Bronn at least M rupees.
As you know, Tyrion cannot lift many bags, so he wants to minimise the number of bags. Also, all the bags should contain the same amount.
Can you help Tyrion in finding the minimum number of bags required?
First line contains T the number of test-cases. The only line of each test case contains four integers –
For each test case, print the minimum number of bags required in one line.
import math for i in range(int(input())): s = [int(x) for x in input().split()] y = max([s,s]) z = min([s,s]) if (s%y == 0 or s%z ==0): f=0 else: r = s%y f = s%z while(r<s): x = r%z if x<f: f = x if x == 0: break else: r = r + y s = s - f print(math.ceil(s/s))