codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1603B.md (1312B)


      1 Source: https://codeforces.com/problemset/problem/1603/B
      2 
      3 B. Moderate Modular Mode
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 Input
     24 
     25 The first line contains a single integer $t$ ($1 \le t \le 10^5$)  — the number of test cases.
     26 
     27 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).
     28 
     29 Output
     30 
     31 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.
     32 
     33 Example
     34 
     35 Input
     36 
     37 ```
     38 4
     39 4 8
     40 4 2
     41 420 420
     42 69420 42068
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 4
     49 10
     50 420
     51 9969128
     52 ```
     53 
     54 Note
     55 
     56 In the first test case, $4 \bmod 4 = 8 \bmod 4 = 0$.
     57 
     58 In the second test case, $10 \bmod 4 = 2 \bmod 10 = 2$.
     59 
     60 In the third test case, $420 \bmod 420 = 420 \bmod 420 = 0$.