Question

C Programming Language Problem Title : Promotion Jojo is at the supermarket buying monthly groceries. As...

C Programming Language

Problem Title : Promotion

Jojo is at the supermarket buying monthly groceries. As he was passing alley by alley, a certain banner caught his interest. Buy K cans of cola and get 1 free while one can of cola costs D dollars. As an avid cola fan, Jojo wouldn’t want to miss this amazing opportunity. Jojo is bad at math and so he asks you to count the price that he needs to pay if he plans to buy N cans of cola.

Format Input

The only line of input contains N , K, and D which denotes the number of cans Jojo is planning to buy, the promotion, and the price of each can consecutively.

Format Output

The output of this problem will only be consisting of the price Jojo needs to pay.

Constraints

  • 1 ≤ N, K, D ≤ 105

Sample Input & Output (1) (standard input & output)

6 3 1

5

Sample Input & Output (2) (standard input & output)

6 3 3

15

Explanation:

In the first & second sample test case, Jojo gets 1 can for free. Thus he only needs to pay for the other 5 cans.

Homework Answers

Answer #1

#include<stdio.h>
int main(){
   long int n,k,d;
   scanf("%ld %ld %ld",&n,&k,&d); //taking inputs n , k, d respectively
   printf("%ld\n",n/(k+1)*k*d+(n%(k+1))*d);// for every k+1 cans we pay for only k cans so n/(k+1)*k*d
                                           //and left over cans(n % k+1) which will be less k+1 we them all
   return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C Programming Language Problem Title : Container Today is Jojo’s birthday. To prepare the birthday party,...
C Programming Language Problem Title : Container Today is Jojo’s birthday. To prepare the birthday party, Jojo asks Bibi to bring N cubes with edge length S for the game on his birthday party. The only idea that came up to Bibi’s mind is to bring the cubes with rectangular box containers. Then Bibi went to a store. The only container available in the store is a container with size A × B × C. Bibi is a thrifty person....
C Programming Language Problem Title : Magical Cave Lili, a great magician, has a mission to...
C Programming Language Problem Title : Magical Cave Lili, a great magician, has a mission to enter a cave to get treasure inside. The cave only has 1 path without branches. But the cave is not safe because there are some traps inside that can reduce Lili’s life points. But in addition to traps, the cave also has potions that can increase Lili’s life points. Before entering the cave, Lili casts magic that can reveal all the traps and potions...
This is a Java program Program Description You work for a local cell phone company and...
This is a Java program Program Description You work for a local cell phone company and have been asked to write a program to calculate the price of a cell phone data plan being purchased by a customer. The program should do the following tasks: Display a menu of the data plans that are available to be purchased. Read in the user’s selection from the menu.  Input Validation: If the user enters an invalid option, the program should display an error...
Note:  100% plagiarism in the above paragraph please remove the plagiarism less than 15 % . CHALLENGES...
Note:  100% plagiarism in the above paragraph please remove the plagiarism less than 15 % . CHALLENGES / OPPORTUNITIES One of the major challenges is to change the people’s perspective of PepsiCo as an unhealthy soft drink producer. Due to the link of soft drinks to obesity and diabetes, the new CEO wants to reinvent Pepsi as a healthy food producer rather than a snacks producer. Although this is a good plan for the PepsiCo to consider, people who are used...
In February 2012, the Pepsi Next product was launched into the US market. This case study...
In February 2012, the Pepsi Next product was launched into the US market. This case study provides students with an interesting insight into PepsiCo’s new product process and some of the challenging decisions that they faced along the way. Pepsi Next Case Study Introduction Pepsi Next was launched by PepsiCo into the US market in February 2012, and has since been rolled out to various international markets (for instance, it was launched in Australia in September 2012). The new product...
1.) True or False? For all societies, resources are scarce, and technology is limited, while people’s...
1.) True or False? For all societies, resources are scarce, and technology is limited, while people’s wants and needs for goods and services seem to be unlimited. (2 points) 2.) (1 point) Adam Smith’s “invisible hand” refers to a.) the subtle and often hidden methods that businesses use to profit at consumers’ expense. b.) the ability of free markets to reach desirable outcomes, despite the self-interest of market participants. c.) the ability of government regulations to benefit consumers, even if...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme values in the data set is the a. range b. median c. mode d. mean 2. If two events are independent, then a. they must be mutually exclusive b. the sum of their probabilities must be equal to one c. their intersection must be zero d. None of these alternatives is correct. any value between 0 to 1 3. Two events, A and B,...
13-19 Describe how Bass Pro Shops became the nation’s leading outdoor retailer based on the retail...
13-19 Describe how Bass Pro Shops became the nation’s leading outdoor retailer based on the retail marketing mix. 13-20 In terms of the major types of retailers, how would you classify Bass Pro Shops? 13-21 Why is Bass Pro Shops succeeding while Cabela’s is floundering? 13-22 Is it a good idea for Bass Pro Shops to acquire Cabela’s? Explain. Outdoor-products megaretailer Bass Pro Shops has seemingly been breaking the rules of retail for more than 40 years, basking in the...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
3 SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to...
3 SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to be used as a basis for class discussion rather than as an illustration of the effective or ineffective handling of an administrative situation. The name of the company is disguised. INTRODUCTION In light of demographic concerns, in 2012, the Japanese government initiated an effort to change the work environment in order to secure the workforce of the future. Japan is world renowned for its...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT