Control the Pollution solution codechef

For Solution
Click Here!
There are two types of vehicles in Chefland.
 Bus which has a capacity of 100100 people.
 Car which has a capacity of 44 people.
There are NN people who want to travel from place AA to place BB. You know that a single bus emits XX units of smoke while a single car emits YY units of smoke in their journey from AA to BB.
You want to arrange some buses and cars to carry all these NN people such that total smoke emitted is minimized. Output the minimized smoke value.
Input Format Control the Pollution solution codechef
 First line will contain TT, the number of test cases. Then the test cases follow.
 Each test case contains three integers NN, XX, YY – the number of people who want to travel, the units of smoke emitted by a bus and the units of smoke emitted by a car respectively.
Output Format
For each test case, output the minimum units of smoke emitted in transporting the NN people.
Constraints
 1≤T≤10001≤T≤1000
 1≤N≤10001≤N≤1000
 1≤X,Y≤10001≤X,Y≤1000
Control the Pollution solution codechef Sample Input 1
3
9 40 8
15 20 20
105 80 10
Sample Output 1
24
20
100
Explanation Control the Pollution solution codechef
Test case1: In the optimal case, we will use 33 cars where the 11st and 22nd car will carry 44 people each and the 33rd car will carry 11 person.
Therefore smoke emitted =3×8=24=3×8=24 units.
Test case2: In the optimal case, we will use 11 bus to carry all the 1515 people.
Therefore smoke emitted =1×20=20=1×20=20 units.
Test case3: In the optimal case, we will use 11 bus to carry 100100 people and use 22 cars to carry the remaining 55 people.
Therefore smoke emitted =1×80+2×10=100=1×80+2×10=100 units.

For Solution
Click Here!