CF2164B.Even Modulo Pair
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a strictly increasing sequence of positive integers a1<a2<…<an. Find two distinct elements x and y from the sequence such that x<y and ymodx is even, or determine that no such pair exists.
pmodq denotes the remainder from dividing p by q.
给定一个严格递增的正整数序列 a1<a2<…<an。请从中找出两个不同的元素 x 和 y,满足 x<y 且 ymodx 为偶数;若不存在这样的数对,则判定其不存在。
pmodq 表示 p 除以 q 所得的余数。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤2⋅104). The description of the test cases follows.
The first line of each test case contains one integer n (2≤n≤105) — the length of the sequence.
The second line of each test case contains n integers a1,a2,…,an (1≤a1<…<an≤109) — the given sequence.
It is guaranteed that the sum of n over all test cases does not exceed 105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤2⋅104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤105)—— 序列的长度。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤a1<…<an≤109)—— 给定的序列。
保证所有测试用例的 n 之和不超过 105。
输出格式
For each test case:
- If no such pair exists, output -1.
- Otherwise, output two integers x and y — the elements that satisfy the condition.
If there are multiple valid pairs, you may output any of them.
对于每个测试用例:
- 如果不存在满足条件的数对,输出
-1。 - 否则,输出两个整数 x 和 y —— 满足条件的元素。
如果存在多个有效的数对,你可以输出其中任意一个。
输入输出样例
输入#1
4 5 1 3 4 5 6 6 2 3 5 7 11 13 4 2 3 13 37 3 17 117 1117
输出#1
3 5 3 11 -1 17 1117
说明/提示
In the first test case, choosing x=3 and y=5 yields ymodx=5mod3=2, which is even.
In the third test case, it is clear that no valid pair exists.
在第一个测试用例中,选择 x=3 和 y=5 可得 ymodx=5mod3=2,该结果为偶数。
在第三个测试用例中,显然不存在满足条件的数对。
输入解题思路,AI测评打分。不知道怎么写?