CF1660A.Vasya and Coins

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya decided to go to the grocery store. He found in his wallet aa coins of 11 burle and bb coins of 22 burles. He does not yet know the total cost of all goods, so help him find out ss (s>0s \gt 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=1a=1 and b=1b=1 (he has one 11-burle coin and one 22-burle coin), then:

  • he can pay 11 burle without change, paying with one 11-burle coin,
  • he can pay 22 burle without change, paying with one 22-burle coin,
  • he can pay 33 burle without change by paying with one 11-burle coin and one 22-burle coin,
  • he cannot pay 44 burle without change (moreover, he cannot pay this amount at all).

So for a=1a=1 and b=1b=1 the answer is s=4s=4.

瓦西娅决定去杂货店购物。他在钱包里找到了 aa 枚面值为 11 布尔的硬币和 bb 枚面值为 22 布尔的硬币。他尚不知道所有商品的总价格,因此请帮助他找出 ss(其中 s>0s \gt 0):他无法仅用这些硬币恰好支付(即不找零)或根本无法支付的最小正整数金额。

例如,若 a=1a=1 且 b=1b=1(即他有一枚 11-布尔硬币和一枚 22-布尔硬币),则:

  • 他可以恰好支付 11 布尔:使用一枚 11-布尔硬币;
  • 他可以恰好支付 22 布尔:使用一枚 22-布尔硬币;
  • 他可以恰好支付 33 布尔:使用一枚 11-布尔硬币和一枚 22-布尔硬币;
  • 他无法恰好支付 44 布尔(而且,他根本无法支付该金额)。

因此,当 a=1a=1 且 b=1b=1 时,答案为 s=4s=4。

输入格式

The first line of the input contains an integer tt (1≤t≤1041 \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 aia_i and bib_i (0≤ai,bi≤1080 \le a_i, b_i \le 10^8) — the number of 11-burle coins and 22-burles coins Vasya has respectively.

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例的描述占一行,包含两个整数 aia_i 和 bib_i(0≤ai,bi≤1080 \le a_i, b_i \le 10^8)—— 分别表示 Vasya 拥有的面值为 11-burle 和 22-burles 的硬币数量。

输出格式

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

对于每个测试用例,在单独一行中输出一个整数 ss(s>0s \gt 0):即瓦西娅无法在不找零的情况下支付、或根本无法支付的最小正整数金额。

输入输出样例

  • 输入#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 11 burle coins, and he can collect either any amount from 11 to 44, but 55 can't.

  • In the second test case, Vasya has only 22 burle coins, and he cannot pay 11 burle without change.

  • In the fourth test case you don't have any coins, and he can't even pay 11 burle.

  • 示例的第一个测试用例已在题干主文中进行了详细说明。

  • 在第二个测试用例中,Vasya 只有 11 枚 1 卢布硬币,他可以凑出 11 至 44 中的任意金额,但无法凑出 55。

  • 在第二个测试用例中,Vasya 只有 22 枚 1 卢布硬币,他无法在不找零的情况下支付 11 卢布。

  • 在第四个测试用例中,你没有任何硬币,因此甚至无法支付 11 卢布。

输入解题思路,AI测评打分。不知道怎么写?

首页