#P1633. Constructing Integers with Given Popcounts and Sum
Constructing Integers with Given Popcounts and Sum
Constructing Integers with Given Popcounts and Sum
Given three positive integers A, B, and C, let \(A_{(2)}\), \(B_{(2)}\), and \(C_{(2)}\) denote their binary representations (without any leading zeros). Let \(L\) be the maximum length (i.e. number of digits) among these three binary representations. Your task is to construct three positive integers X, Y, and Z satisfying:
- The binary representations of X, Y, and Z each have at most \(L\) digits.
- The number of 1's in \(X_{(2)}\) is equal to the number of 1's in \(A_{(2)}\).
- The number of 1's in \(Y_{(2)}\) is equal to the number of 1's in \(B_{(2)}\).
- The number of 1's in \(Z_{(2)}\) is equal to the number of 1's in \(C_{(2)}\).
- \(X+Y=Z\).
All binary representations are presented in \(\LaTeX\) format (for example, \(N_{(2)}\) represents the binary representation of \(N\)). It is guaranteed that the input values admit a solution. If there is no solution under some circumstances, you may output -1.
inputFormat
The input consists of one line containing three space-separated positive integers A, B, and C.
outputFormat
Output three space‐separated positive integers X, Y, and Z satisfying the conditions above. If no solution exists, output -1.
sample
1 1 2
1 1 2