OpenGenus / cosmos

World's largest Contributor driven code dataset | Used in Quark Search Engine, @OpenGenus IQ, OpenGenus Visual Project
http://internship.opengenus.org
GNU General Public License v3.0
13.56k stars 3.67k forks source link

Hackerrank Taum and Bday solution in C #5495

Open ritish099 opened 4 years ago

ritish099 commented 4 years ago

This is a(n):

Details:

Taum is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Taum: one is black and the other is white. To make her happy, Taum has to buy b black gifts and w white gifts.

The cost of each black gift is bc units. The cost of every white gift is wc units. The cost of converting each black gift into white gift or vice versa is z units. Help Taum by deducing the minimum amount he needs to spend on Diksha's gifts.

For example, if Taum wants to buy b=3 black gifts and w=5 white gifts at a cost of bc = 3, wc = 4 and conversion cost z = 1, we see that he can buy a black gift for 3 and convert it to a white gift for 1, making the total cost of each white gift

  1. That matches the cost of a white gift, so he can do that or just buy black gifts and white gifts. Either way, the overall cost is 3 3 + 5 4 = 29.
arpitasahakundu commented 4 years ago

Want to work. On this