Buy Lamps Codechef Problem Solution
An electronics shop sells red and blue lamps. A red lamp costs
Chef is going to buy exactly
Input Format
- The first line of input will contain a single integer
T , denoting the number of test cases. - Each test case consists of a single line containing four space-separated integers
N,K,X,Y
Output Format
For each test case, output on a new line the minimum amount of money Chef needs to pay in order to buy
Constraints
1≤T≤10 ^ 3 1≤N≤10 ^ 8 0≤K≤N 1≤X,Y≤10
Sample Input 1
4
2 2 5 1
4 1 3 1
3 0 4 7
5 2 3 4
Sample Output 1
10
6
12
15
Explanation
Test case
Test case
Test case
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int k=sc.nextInt();
int x=sc.nextInt();
int y=sc.nextInt();
int r=n-k;
int ans = k*x;
int a=x
0 Comments