Hackerrank solutions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
560 B

#!/usr/bin/python3
# https://www.hackerrank.com/challenges/chocolate-feast
import sys
def num_chocolates(money, cost, exchange):
choco = money // cost
wrappers = choco
while wrappers > exchange:
exch_choco, wrappers = divmod(wrappers, exchange)
wrappers += exch_choco
choco += exch_choco
return choco
def main():
T = int(sys.stdin.readline())
for _ in range(T):
[N, C, M] = [ int(x) for x in sys.stdin.readline().split() ]
print(num_chocolates(N, C, M))
if __name__ == '__main__':
main()