Navi and beer
Practice
3.3 (169 votes)
Implementation
Basic programming
Very Easy
Ready
Mathematics
Approved
Problem
24% Success 6251 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Navi is at the Beer Bar where he has ordered N beers. After seeing his love with the beers, Bar's Manager has decided to make as much money as they can by asking Navi to pay K * i3 Rupees for the ith beer. But Navi has only M Rupees in his purse. So you are required to lent him some money so that he can still be able to pay for all of the N beers.
Input:
- First line will contain T (No. of test cases).
- Each test case will contain only one line having three space separated integers : N, K and M
Output:
- For every test case, print the required answer in a new line.
- 1 ≤ T ≤ 105
- 1 ≤ N, K ≤ 103
- 1 ≤ M ≤ 106
Sample Code:
#include
using namespace std;
int main()
{
//taking input for number of test cases, T.
cin>>T;
//For every test case, taking input for N , K and M.
cin>>N>>K>>M;
//let the answer be in variable **Ans**
cout << Ans << endl; //print your answer for every test case.
return 0;
}
Explanation
Total Money required is : 2 * 13 + 2 * 23 = 18 but he already has 10 so ans is 8.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
Tags:
Dynamic ProgrammingHardHeavy light decompositionAlgorithmsOpenApprovedAlgorithmsDisjoint set
Points:30
402 votes
Tags:
Brute-force searchEasy-MediumGreedy algorithm
Points:30
9 votes
Tags:
ApprovedCombinatoricsMathMediumNumber TheoryOpen
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output