Codey and Textbooks
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-closed-category/challenges/cn-c4
Question
Codey, who is enthusiastic when it comes to studies, is eager to purchase n textbooks from the university bookstore. These textbooks are priced in an interesting way:
The first textbook costs dollars.
The second textbook costs dollars.
The -th textbook costs dollars.
Codey has k dollars in his wallet, but it's wondering how much it needs to borrow from the E-bee to cover the costs of purchasing n textbooks.
Your task is to calculate and output the amount of money that Codey has to borrow from the E-bee. If it doesn't need to borrow any money, the answer should be .
Can you assist Codey in figuring out how much it needs to borrow from E-Bee, if at all?
Input Format
The first line contains three integers n, m, k, where n represents the number of textbooks Codey wants, m represents the cost of the first book, and k represents the initial number of ringgit Codey has.
Constraints
Output Format
Outputs only one integer, the amount of money Codey has to borrow from E-bee. If it doesn't have to borrow money from E-bee, output 0.
Sample Inputs:
Last updated