luogu#P10862. [HBCPC2024] Spicy or Grilled?

[HBCPC2024] Spicy or Grilled?

题目描述

Since a regular programming contest lasts for five hours, it's a big problem to prepare contestants' food during the contest.

In the 20XX International Collegiate Programming Contest in Hubei Province, China, there were nn contestants participating in the contest. The host wanted to prepare a Spicy Chicken Burger Set for every contestant, which was aa dollars per set at that time. But since there were some people who could not bear the spiciness like Walk Alone, a Grilled Chicken Burger Set was prepared for these people, which was bb dollars per set. Before the contest, the host had collected the number xx of people who wanted to eat a Grilled Chicken Burger Set.

But Walk Alone was too stupid and lazy to calculate how much the host would spend. Please help him to calculate.

输入格式

In the first line,there is an integer TT (1T1041 \leq T \leq 10^4) denoting the number of test cases.

For each test case, there are four integers nn, xx, aa and bb (1n,a,b104,0xn1 \leq n, a, b \leq 10^4, 0 \le x \le n) in each line, representing the number of contestants in total, the number of contestants who want Grilled Chicken Burger Set, the price of Spicy Chicken Burger Set and Grilled Chicken Burger Set per set.

输出格式

For each test case, output a single integer denoting the total money the host would spend.

3
600 200 27 26
750 0 26 27
750 750 1 1
16000
19500
750

提示

In the first test case, there were 400400 people chosen the Spicy Chicken Burger Set and 200200 people chosen the Grilled one. So the total money is 400×27+200×26=16 000400 \times 27 + 200 \times 26 = 16\ 000 dollars.