Browse Source

Solved Chocolate Feast

main
Titouan Rigoudy 11 years ago
parent
commit
4d0be1b7b0
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      chocolate_feast/chocolate_feast.py

+ 23
- 0
chocolate_feast/chocolate_feast.py View File

@ -0,0 +1,23 @@
#!/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()

Loading…
Cancel
Save