CF2164B.Even Modulo Pair

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a strictly increasing sequence of positive integers a1<a2<…<ana_1 \lt a_2 \lt \ldots \lt a_n. Find two distinct elements xx and yy from the sequence such that x<yx \lt y and y mod xy \bmod x is even, or determine that no such pair exists.

p mod qp \bmod q denotes the remainder from dividing pp by qq.

给定一个严格递增的正整数序列 a1<a2<…<ana_1 \lt a_2 \lt \ldots \lt a_n。请从中找出两个不同的元素 xx 和 yy,满足 x<yx \lt y 且 y mod xy \bmod x 为偶数;若不存在这样的数对,则判定其不存在。

p mod qp \bmod q 表示 pp 除以 qq 所得的余数。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤2⋅1041 \le t \le 2\cdot 10^4). The description of the test cases follows.

The first line of each test case contains one integer nn (2≤n≤1052 \le n \le 10^5) — the length of the sequence.

The second line of each test case contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n (1≤a1<…<an≤1091\le a_1 \lt \ldots \lt a_n\le 10^9) — the given sequence.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤2⋅1041 \le t \le 2\cdot 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤1052 \le n \le 10^5)—— 序列的长度。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1,a_2,\ldots,a_n(1≤a1<…<an≤1091\le a_1 \lt \ldots \lt a_n\le 10^9)—— 给定的序列。

保证所有测试用例的 nn 之和不超过 10510^5。

输出格式

For each test case:

  • If no such pair exists, output -1.
  • Otherwise, output two integers xx and yy — the elements that satisfy the condition.

If there are multiple valid pairs, you may output any of them.

对于每个测试用例:

  • 如果不存在满足条件的数对,输出 -1。
  • 否则,输出两个整数 xx 和 yy —— 满足条件的元素。

如果存在多个有效的数对,你可以输出其中任意一个。

输入输出样例

  • 输入#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

说明/提示

Visualizer link

In the first test case, choosing x=3x = 3 and y=5y = 5 yields y mod x=5 mod 3=2y \bmod x = 5 \bmod 3 = 2, which is even.

In the third test case, it is clear that no valid pair exists.

可视化链接

在第一个测试用例中,选择 x=3x = 3 和 y=5y = 5 可得 y mod x=5 mod 3=2y \bmod x = 5 \bmod 3 = 2,该结果为偶数。

在第三个测试用例中,显然不存在满足条件的数对。

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

首页