Algorithm
problrm Link : https://www.codechef.com/problems/PRIZEPOOL
Problem
In a coding contest, there are prizes for the top rankers. The prize scheme is as follows:
- Top participants receive rupees each.
- Participants with rank to (both inclusive) receive rupees each.
Find the total prize money over all the contestants.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- Each test case contains of a single line of input, two integers and - the prize for top rankers and the prize for ranks to respectively.
Output Format
For each test case, output the total prize money over all the contestants.
Constraints
Sample 1:
4 1000 100 1000 1000 80 1 400 30
19000 100000 890 6700
Explanation:
Test Case : Top participants receive rupees and next participants receive rupees each. So, total prize money .
Test Case : Top participants receive rupees and next participants receive rupees each. So, total prize money .
Test Case : Top participants receive rupees and next participants receive rupee each. So, total prize money .
Test Case : Top participants receive rupees and next participants receive rupees each. So, total prize money .
Code Examples
AdvertisementsDemonstration
CodeChef solution PRIZEPOOL - Total Prize Money Codechef solution in C,C++