A14574 | Moderate Modular Mode
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
YouKn0wWho has two even integers $x$ and $y$ . Help him to find an integer $n$ such that $1 \le n \le 2 \cdot 10^{18}$ and $n \bmod x = y \bmod n$ . Here, $a \bmod b$ denotes the remainder of $a$ after division by $b$ . 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 $t$ ( $1 \le t \le 10^5$ ) — the number of test cases.
The first and only line of each test case contains two integers $x$ and $y$ ( $2 \le x, y \le 10^9$ , both are even).
The first and only line of each test case contains two integers $x$ and $y$ ( $2 \le x, y \le 10^9$ , both are even).
输出格式
For each test case, print a single integer $n$ ( $1 \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, $4 \bmod 4 = 8 \bmod 4 = 0$ .
In the second test case, $10 \bmod 4 = 2 \bmod 10 = 2$ .
In the third test case, $420 \bmod 420 = 420 \bmod 420 = 0$ .
In the second test case, $10 \bmod 4 = 2 \bmod 10 = 2$ .
In the third test case, $420 \bmod 420 = 420 \bmod 420 = 0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted