310156: CF1790E. Vlad and a Pair of Numbers

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Vlad and a Pair of Numbers

题意翻译

共有 $t$ 组数据。 每组数据你会得到一个正整数 $x$,你需要构造一组正整数 $a$ 和 $b$,满足: - $a + b = x \times 2$; - $a \operatorname{xor} b = x$,其中 $\operatorname{xor}$ 指异或。 输出你构造的 $a$ 和 $b$。如有多解,任意输出一解即可。如无解,输出 $-1$。 $1 \leq t \leq 10^4$,$1 \leq x \leq 2^{29}$。同时,你需要保证你构造的 $a$,$b$ 满足 $1 \leq a,b \leq 2^{30}$。

题目描述

Vlad found two positive numbers $ a $ and $ b $ ( $ a,b>0 $ ). He discovered that $ a \oplus b = \frac{a + b}{2} $ , where $ \oplus $ means the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) , and division is performed without rounding.. Since it is easier to remember one number than two, Vlad remembered only $ a\oplus b $ , let's denote this number as $ x $ . Help him find any suitable $ a $ and $ b $ or tell him that they do not exist.

输入输出格式

输入格式


The first line of the input data contains the single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases in the test. Each test case is described by a single integer $ x $ ( $ 1 \le x \le 2^{29} $ ) — the number that Vlad remembered.

输出格式


Output $ t $ lines, each of which is the answer to the corresponding test case. As the answer, output $ a $ and $ b $ ( $ 0 < a,b \le 2^{32} $ ), such that $ x = a \oplus b = \frac{a + b}{2} $ . If there are several answers, output any of them. If there are no matching pairs, output -1.

输入输出样例

输入样例 #1

6
2
5
10
6
18
36

输出样例 #1

3 1
-1
13 7
-1
25 11
50 22

Input

题意翻译

共有 $t$ 组数据。 每组数据你会得到一个正整数 $x$,你需要构造一组正整数 $a$ 和 $b$,满足: - $a + b = x \times 2$; - $a \operatorname{xor} b = x$,其中 $\operatorname{xor}$ 指异或。 输出你构造的 $a$ 和 $b$。如有多解,任意输出一解即可。如无解,输出 $-1$。 $1 \leq t \leq 10^4$,$1 \leq x \leq 2^{29}$。同时,你需要保证你构造的 $a$,$b$ 满足 $1 \leq a,b \leq 2^{30}$。

Output

**题意翻译**

题目描述了 Vlad 有一个正整数 $ x $,他需要找到两个正整数 $ a $ 和 $ b $,使得:

- $ a + b = x \times 2 $;
- $ a \oplus b = x $,其中 $ \oplus $ 表示按位异或操作。

你的任务是帮助 Vlad 找到这样的一对 $ a $ 和 $ b $,如果有多个解,输出任意一个即可;如果没有解,则输出 -1。

输入数据保证 $ 1 \leq t \leq 10^4 $,$ 1 \leq x \leq 2^{29} $,并且你构造的 $ a $ 和 $ b $ 需要满足 $ 1 \leq a,b \leq 2^{30} $。

**输入输出格式**

**输入格式**

输入数据的第一行包含一个整数 $ t $($ 1 \le t \le 10^4 $),表示测试用例的数量。

每个测试用例由一个整数 $ x $($ 1 \le x \le 2^{29} $)描述,表示 Vlad 记住的数字。

**输出格式**

输出 $ t $ 行,每行是对应测试用例的答案。输出满足 $ x = a \oplus b = \frac{a + b}{2} $ 的 $ a $ 和 $ b $($ 0 < a,b \le 2^{32} $)。如果有多个答案,输出其中任意一个。如果没有符合条件的数对,输出 -1。

**输入输出样例**

**输入样例 #1**

```
6
2
5
10
6
18
36
```

**输出样例 #1**

```
3 1
-1
13 7
-1
25 11
50 22
```**题意翻译** 题目描述了 Vlad 有一个正整数 $ x $,他需要找到两个正整数 $ a $ 和 $ b $,使得: - $ a + b = x \times 2 $; - $ a \oplus b = x $,其中 $ \oplus $ 表示按位异或操作。 你的任务是帮助 Vlad 找到这样的一对 $ a $ 和 $ b $,如果有多个解,输出任意一个即可;如果没有解,则输出 -1。 输入数据保证 $ 1 \leq t \leq 10^4 $,$ 1 \leq x \leq 2^{29} $,并且你构造的 $ a $ 和 $ b $ 需要满足 $ 1 \leq a,b \leq 2^{30} $。 **输入输出格式** **输入格式** 输入数据的第一行包含一个整数 $ t $($ 1 \le t \le 10^4 $),表示测试用例的数量。 每个测试用例由一个整数 $ x $($ 1 \le x \le 2^{29} $)描述,表示 Vlad 记住的数字。 **输出格式** 输出 $ t $ 行,每行是对应测试用例的答案。输出满足 $ x = a \oplus b = \frac{a + b}{2} $ 的 $ a $ 和 $ b $($ 0 < a,b \le 2^{32} $)。如果有多个答案,输出其中任意一个。如果没有符合条件的数对,输出 -1。 **输入输出样例** **输入样例 #1** ``` 6 2 5 10 6 18 36 ``` **输出样例 #1** ``` 3 1 -1 13 7 -1 25 11 50 22 ```

加入题单

算法标签: