309303: CF1660A. Vasya and Coins

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:18 Solved:0

Description

Vasya and Coins

题意翻译

### 题目描述 Vasya决定去一趟小卖部。他发现他的钱包里有 $a$ 枚价值 $1$ 波尔的硬币和 $b$ 枚价值 $2$ 波尔的硬币。他还不知道所有商品的总价,所以请你帮他找出 $s$ $(s \ge 0)$ , 即为他需要找零或无法只用他自己的硬币支付的最小正整数金额。 举个例子,如果 $a=1$ , $b=1$ ,即他有 $1$ 枚价值 $1$ 卢布的硬币和 $1$ 枚价值 $2$ 卢布的硬币: - 他不找零也能支付 $1$ 波尔,只需要支付 $1$ 枚价值 $1$ 波尔的硬币, - 他不找零也能支付 $2$ 波尔,只需要支付 $1$ 枚价值 $2$ 波尔的硬币, - 他不找零也能支付 $3$ 波尔,只需要支付 $1$ 枚价值 $1$ 波尔的硬币和 $1$ 枚价值 $2$ 波尔的硬币, - 他无法不找零就支付 $4$ 波尔(而且他根本就付不起这笔钱) 所以当 $a=1$ , $b=1$ 时,答案是 $s=4$ 。 ### 输入格式 第一行输入一个整数 $t\ (1 \le t \le 10^4)$ , 表示测试数据组数。 每一组测试样例的数据包括两个整数 $a_i$ , $b_i$ $(0 \le a_i,b_i \le 10^8)$ , 表示 Vasya 拥有的价值为 $1$ 波尔的硬币数量和价值为 $2$ 波尔的硬币数量。 ### 输出格式 每个测试数据在单独一行中输出一个整数 $s$ 。 ### 说明/提示 - 测试样例1已在题面部分说明。 - 在测试样例2中,Vasya只有价值为 $1$ 波尔的硬币,且他可以支付 $1$ 至 $4$ 波尔之间的任意值,但无法支付 $5$ 波尔。 - 在测试样例3中,Vasya只有价值为 $2$ 波尔的硬币,所以他无法不找零支付 $1$ 波尔。 - 在测试样例4中,Vasya没有硬币,所以他付不起 $1$ 波尔。

题目描述

Vasya decided to go to the grocery store. He found in his wallet $ a $ coins of $ 1 $ burle and $ b $ coins of $ 2 $ burles. He does not yet know the total cost of all goods, so help him find out $ s $ ( $ s > 0 $ ): the minimum positive integer amount of money he cannot pay without change or pay at all using only his coins. For example, if $ a=1 $ and $ b=1 $ (he has one $ 1 $ -burle coin and one $ 2 $ -burle coin), then: - he can pay $ 1 $ burle without change, paying with one $ 1 $ -burle coin, - he can pay $ 2 $ burle without change, paying with one $ 2 $ -burle coin, - he can pay $ 3 $ burle without change by paying with one $ 1 $ -burle coin and one $ 2 $ -burle coin, - he cannot pay $ 4 $ burle without change (moreover, he cannot pay this amount at all). So for $ a=1 $ and $ b=1 $ the answer is $ s=4 $ .

输入输出格式

输入格式


The first line of the input contains an integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases in the test. The description of each test case consists of one line containing two integers $ a_i $ and $ b_i $ ( $ 0 \le a_i, b_i \le 10^8 $ ) — the number of $ 1 $ -burle coins and $ 2 $ -burles coins Vasya has respectively.

输出格式


For each test case, on a separate line print one integer $ s $ ( $ s > 0 $ ): the minimum positive integer amount of money that Vasya cannot pay without change or pay at all.

输入输出样例

输入样例 #1

5
1 1
4 0
0 2
0 0
2314 2374

输出样例 #1

4
5
1
1
7063

说明

- The first test case of the example is clarified into the main part of the statement. - In the second test case, Vasya has only $ 1 $ burle coins, and he can collect either any amount from $ 1 $ to $ 4 $ , but $ 5 $ can't. - In the second test case, Vasya has only $ 2 $ burle coins, and he cannot pay $ 1 $ burle without change. - In the fourth test case you don't have any coins, and he can't even pay $ 1 $ burle.

Input

题意翻译

### 题目描述 Vasya决定去一趟小卖部。他发现他的钱包里有 $a$ 枚价值 $1$ 波尔的硬币和 $b$ 枚价值 $2$ 波尔的硬币。他还不知道所有商品的总价,所以请你帮他找出 $s$ $(s \ge 0)$ , 即为他需要找零或无法只用他自己的硬币支付的最小正整数金额。 举个例子,如果 $a=1$ , $b=1$ ,即他有 $1$ 枚价值 $1$ 卢布的硬币和 $1$ 枚价值 $2$ 卢布的硬币: - 他不找零也能支付 $1$ 波尔,只需要支付 $1$ 枚价值 $1$ 波尔的硬币, - 他不找零也能支付 $2$ 波尔,只需要支付 $1$ 枚价值 $2$ 波尔的硬币, - 他不找零也能支付 $3$ 波尔,只需要支付 $1$ 枚价值 $1$ 波尔的硬币和 $1$ 枚价值 $2$ 波尔的硬币, - 他无法不找零就支付 $4$ 波尔(而且他根本就付不起这笔钱) 所以当 $a=1$ , $b=1$ 时,答案是 $s=4$ 。 ### 输入格式 第一行输入一个整数 $t\ (1 \le t \le 10^4)$ , 表示测试数据组数。 每一组测试样例的数据包括两个整数 $a_i$ , $b_i$ $(0 \le a_i,b_i \le 10^8)$ , 表示 Vasya 拥有的价值为 $1$ 波尔的硬币数量和价值为 $2$ 波尔的硬币数量。 ### 输出格式 每个测试数据在单独一行中输出一个整数 $s$ 。 ### 说明/提示 - 测试样例1已在题面部分说明。 - 在测试样例2中,Vasya只有价值为 $1$ 波尔的硬币,且他可以支付 $1$ 至 $4$ 波尔之间的任意值,但无法支付 $5$ 波尔。 - 在测试样例3中,Vasya只有价值为 $2$ 波尔的硬币,所以他无法不找零支付 $1$ 波尔。 - 在测试样例4中,Vasya没有硬币,所以他付不起 $1$ 波尔。

加入题单

算法标签: