CF1603B.Moderate Modular Mode

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

YouKn0wWho has two even integers xx and yy . Help him to find an integer nn such that 1n210181 \le n \le 2 \cdot 10^{18} and nmodx=ymodnn \bmod x = y \bmod n . Here, amodba \bmod b denotes the remainder of aa after division by bb . If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.

输入格式

The first line contains a single integer tt ( 1t1051 \le t \le 10^5 ) — the number of test cases.

The first and only line of each test case contains two integers xx and yy ( 2x,y1092 \le x, y \le 10^9 , both are even).

输出格式

For each test case, print a single integer nn ( 1n210181 \le n \le 2 \cdot 10^{18} ) that satisfies the condition mentioned in the statement. If there are multiple such integers, output any. It can be shown that such an integer always exists under the given constraints.

输入输出样例

  • 输入#1

    4
    4 8
    4 2
    420 420
    69420 42068

    输出#1

    4
    10
    420
    9969128

说明/提示

In the first test case, 4mod4=8mod4=04 \bmod 4 = 8 \bmod 4 = 0 .

In the second test case, 10mod4=2mod10=210 \bmod 4 = 2 \bmod 10 = 2 .

In the third test case, 420mod420=420mod420=0420 \bmod 420 = 420 \bmod 420 = 0 .

首页