CF1603B.Moderate Modular Mode

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

YouKn0wWho has two even integers xx and yy. Help him to find an integer nn such that 1≤n≤2⋅10181 \le n \le 2 \cdot 10^{18} and n mod x=y mod nn \bmod x = y \bmod n. Here, a mod ba \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.

YouKn0wWho 有两个偶数 xx 和 yy。请帮他找出一个整数 nn,使得 1≤n≤2⋅10181 \le n \le 2 \cdot 10^{18} 且满足 n mod x=y mod nn \bmod x = y \bmod n。其中,a mod ba \bmod b 表示 aa 除以 bb 后的余数。若存在多个满足条件的整数,输出任意一个即可。在给定约束下,可以证明这样的整数一定存在。

输入格式

The first line contains a single integer tt (1≤t≤1051 \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 (2≤x,y≤1092 \le x, y \le 10^9, both are even).

第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5)—— 测试用例的数量。

每个测试用例仅有一行,包含两个整数 xx 和 yy(2≤x,y≤1092 \le x, y \le 10^9,且均为偶数)。

输出格式

For each test case, print a single integer nn (1≤n≤2⋅10181 \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.

对于每个测试用例,输出一个满足题目陈述中所述条件的整数 nn(1≤n≤2⋅10181 \le n \le 2 \cdot 10^{18})。如果存在多个满足条件的整数,输出任意一个即可。在给定约束下,可以证明这样的整数一定存在。

输入输出样例

  • 输入#1

    4
    4 8
    4 2
    420 420
    69420 42068

    输出#1

    4
    10
    420
    9969128

说明/提示

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

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

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

在第一个测试用例中,4 mod 4=8 mod 4=04 \bmod 4 = 8 \bmod 4 = 0。

在第二个测试用例中,10 mod 4=2 mod 10=210 \bmod 4 = 2 \bmod 10 = 2。

在第三个测试用例中,420 mod 420=420 mod 420=0420 \bmod 420 = 420 \bmod 420 = 0。

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

首页