Problem Statement:
Little Bobby loves chocolate, and he frequently goes to his favorite store, Penny Auntie, with dollars to buy chocolates. Each chocolate has a flat cost of dollars, and the store has a promotion where they allow you to trade in chocolate wrappers in exchange for free piece of chocolate.
For example, if and Bobby has dollars that he uses to buy chocolates at dollar apiece, he can trade in the wrappers to buy more chocolates. Now he has more wrappers that he can trade in for more chocolate. Because he only has wrapper left at this point and , he was only able to eat a total of pieces of chocolate.
Given , , and for trips to the store, can you determine how many chocolates Bobby eats during each trip?
Input Format
The first line contains an integer, , denoting the number of trips Bobby makes to the store.
Each line of the subsequent lines contains three space-separated integers describing the respective , , and values for one of Bobby's trips to the store.
Each line of the subsequent lines contains three space-separated integers describing the respective , , and values for one of Bobby's trips to the store.
Constraints
Output Format
For each trip to Penny Auntie, print the total number of chocolates Bobby eats on a new line.
Problem Solution using python 2.7.6:
t =
input()
while t:
chocolates,wrappers,ExchangeChocolates = 0,0,0
n,c,m = map(int,raw_input().split(' '))
chocolates = n/c
wrappers = chocolates
ExchangeChocolates = wrappers/m
while wrappers >= m:
ExchangeChocolates = ExchangeChocolates
+ (wrappers/m + wrappers % m)/m
wrappers = wrappers/m
print chocolates+ExchangeChocolates
t -=1
If you're trying to lose kilograms then you certainly need to jump on this brand new personalized keto meal plan.
ReplyDeleteTo create this keto diet service, certified nutritionists, fitness trainers, and chefs have united to provide keto meal plans that are productive, decent, money-efficient, and satisfying.
From their grand opening in early 2019, thousands of people have already completely transformed their body and health with the benefits a certified keto meal plan can give.
Speaking of benefits: in this link, you'll discover eight scientifically-certified ones given by the keto meal plan.