P17366 [CodeChef] CANDYSTORE
普及-
题目描述

Chef has started working at the candy store. The store has 100 chocolates in total.

Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee.
However, if Chef exceeds his daily goal, he gets 2 rupees per chocolate for each extra chocolate.

If Chef sells Y chocolates in a day, find the total amount he made.

------ Input Format ------

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers X and Y — the daily goal of Chef, and the number of chocolates he actually sells.

------ Output Format ------

For each test case, output on a new line the total amount Chef made in a day.

------ Constraints ------

$1 ≤ T ≤ 100$
$1 ≤ X, Y ≤ 10$

----- Sample Input 1 ------
4
3 1
5 5
4 7
2 3

----- Sample Output 1 ------
1
5
10
4

----- explanation 1 ------
Test case $1$: Chef's daily goal was $3$. Since he sold only $1$ chocolate, he'll get only $1$ rupee.

Test case $2$: Chef's daily goal was $5$. Since he sold $5$ chocolates, he'll get $5$ rupees.

Test case $3$: Chef's daily goal was $4$. Since he sold $7$ chocolate, he'll get $4$ rupees for the $4$ chocolates as his daily goal and $2$ rupees per chocolate for the extra $3$ chocolates. The total amount he gets is $4+3\cdot 2 = 10$.

Test case $4$: Chef's daily goal was $2$. Since he sold $3$ chocolate, he'll get $2$ rupees for the $2$ chocolates as his daily goal and $2$ rupees per chocolate for the extra $1$ chocolate. The total amount he gets is $2+1\cdot 2 = 4$.

输入格式

见题面

输出格式

见题面

样例输入
4 3 1 5 5 4 7 2 3
样例输出
1 5 10 4