#abc347d. D - Popcount and XOR

D - Popcount and XOR

Score: 400400 points

问题陈述

给定非负整数 aabbCC。确定是否存在一对非负整数 (X,Y)(X, Y) 满足以下五个条件。如果存在这样的一对,打印出来。

  • 0X<2600 \leq X < 2^{60}
  • 0Y<2600 \leq Y < 2^{60}
  • popcount(X)=a\operatorname{popcount}(X) = a
  • popcount(Y)=b\operatorname{popcount}(Y) = b
  • XY=CX \oplus Y = C

这里,\oplus 表示按位异或。

如果多个一对 (X,Y)(X, Y) 满足条件,你可以打印出其中任意一个。

什么是popcount?

对于非负整数 xxxx 的popcount是其二进制表示中1的个数。更精确地说,对于非负整数 xx,使得 $\displaystyle x=\sum _ {i=0} ^ \infty b _ i2 ^ i\ (b _ i\in\lbrace0,1\rbrace)$,我们有 $\displaystyle\operatorname{popcount}(x)=\sum _ {i=0} ^ \infty b _ i$。

例如,二进制表示中 13131101,所以 popcount(13)=3\operatorname{popcount}(13)=3。什么是按位异或?

对于非负整数 x,yx, y,按位异或 xyx \oplus y 定义如下。

  • 二进制表示中 xyx \oplus y2k2^k 的位置  (k0)\ (k\geq0) 如果 xxyy 的二进制表示中 2k2^k 的位置  (k0)\ (k\geq0) 只有一个是1,则为1,否则为0。

例如,二进制表示中 9933 分别是 10010011,所以 93=109 \oplus 3 = 10(二进制表示为 1010)。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given non-negative integers aa, bb, and CC. Determine if there is a pair of non-negative integers (X,Y)(X, Y) that satisfies all of the following five conditions. If such a pair exists, print one.

  • 0X<2600 \leq X < 2^{60}
  • 0Y<2600 \leq Y < 2^{60}
  • popcount(X)=a\operatorname{popcount}(X) = a
  • popcount(Y)=b\operatorname{popcount}(Y) = b
  • XY=CX \oplus Y = C

Here, \oplus denotes the bitwise XOR.

If multiple pairs (X,Y)(X, Y) satisfy the conditions, you may print any of them.

What is popcount?

For a non-negative integer xx, the popcount of xx is the number of 11s in the binary representation of xx. More precisely, for a non-negative integer xx such that $\displaystyle x=\sum _ {i=0} ^ \infty b _ i2 ^ i\ (b _ i\in\lbrace0,1\rbrace)$, we have $\displaystyle\operatorname{popcount}(x)=\sum _ {i=0} ^ \infty b _ i$.

For example, 1313 in binary is 1101, so popcount(13)=3\operatorname{popcount}(13)=3. What is bitwise XOR?

For non-negative integers x,yx, y, the bitwise exclusive OR xyx \oplus y is defined as follows.

  • The 2k2^k's place  (k0)\ (k\geq0) in the binary representation of xyx \oplus y is 11 if exactly one of the 2k2^k's places  (k0)\ (k\geq0) in the binary representations of xx and yy is 11, and 00 otherwise.

For example, 99 and 33 in binary are 1001 and 0011, respectively, so 93=109 \oplus 3 = 10 (in binary, 1010).

Constraints

  • 0a600 \leq a \leq 60
  • 0b600 \leq b \leq 60
  • 0C<2600 \leq C < 2^{60}
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

aa bb CC

Output

If there is a pair of non-negative integers that satisfies the conditions, choose one such pair (X,Y)(X, Y) and print XX and YY in this order, with a space in between. If no such pair exists, print -1.

Sample Input 1

3 4 7

Sample Output 1

28 27

The pair (X,Y)=(28,27)(X, Y) = (28, 27) satisfies the conditions. Here, XX and YY in binary are 11100 and 11011, respectively.

  • XX in binary is 11100, so popcount(X)=3\operatorname{popcount}(X) = 3.
  • YY in binary is 11011, so popcount(Y)=4\operatorname{popcount}(Y) = 4.
  • XYX \oplus Y in binary is 00111, so XY=7X \oplus Y = 7.

If multiple pairs of non-negative integers satisfy the conditions, you may print any of them, so printing 42 45, for example, would also be accepted.

Sample Input 2

34 56 998244353

Sample Output 2

-1

No pair of non-negative integers satisfies the conditions.

Sample Input 3

39 47 530423800524412070

Sample Output 3

540431255696862041 10008854347644927

Note that the values to be printed may not fit in 3232-bit integers.