URI Online Judge Solution 2896 Enjoy the Offer Using Python Programming Language.
A supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest.
Make a program to calculate this.
Input
The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full.
Output
For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer.
Input Sample | Output Sample |
3 | 4 |
URI 2896 Solution in Python:
T = int(input())
S = 0
while T>0:
X,Y = map(int,input().split())
if X>=Y:
S = S + X/Y
S = S + X%Y
else:
S = X
print(int(S))
S = 0
T-=1
Comments
Post a Comment