codeforces-scrape

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

2164B.md (1621B)


      1 Source: https://codeforces.com/problemset/problem/2164/B
      2 
      3 B. Even Modulo Pair
      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 You are given a strictly increasing sequence of positive integers $a_1 \lt a_2 \lt \ldots \lt a_n$. Find two distinct elements $x$ and $y$ from the sequence such that $x \lt y$ and $y \bmod x$ is even, or determine that no such pair exists.
     22 
     23 $p \bmod q$ denotes the remainder from dividing $p$ by $q$.
     24 
     25 Input
     26 
     27 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 2\cdot 10^4$). The description of the test cases follows.
     28 
     29 The first line of each test case contains one integer $n$ ($2 \le n \le 10^5$) — the length of the sequence.
     30 
     31 The second line of each test case contains $n$ integers $a_1,a_2,\ldots,a_n$ ($1\le a_1 \lt \ldots \lt a_n\le 10^9$) — the given sequence.
     32 
     33 It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
     34 
     35 Output
     36 
     37 For each test case:
     38 
     39 * If no such pair exists, output -1.
     40 * Otherwise, output two integers $x$ and $y$ — the elements that satisfy the condition.
     41 
     42 If there are multiple valid pairs, you may output any of them.
     43 
     44 Example
     45 
     46 Input
     47 
     48 ```
     49 4
     50 
     51 5
     52 
     53 1 3 4 5 6
     54 
     55 6
     56 
     57 2 3 5 7 11 13
     58 
     59 4
     60 
     61 2 3 13 37
     62 
     63 3
     64 
     65 17 117 1117
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 3 5
     72 3 11
     73 -1
     74 17 1117
     75 ```
     76 
     77 Note
     78 
     79 [Visualizer link](https://codeforces.com/assets/contests/2164/B_ohw7aeph4eewahwooF1N.html)
     80 
     81 In the first test case, choosing $x = 3$ and $y = 5$ yields $y \bmod x = 5 \bmod 3 = 2$, which is even.
     82 
     83 In the third test case, it is clear that no valid pair exists.