#B4261. Finding Minimal y for Bitwise Equation

    ID: 11918 Type: Default 1000ms 256MiB

Finding Minimal y for Bitwise Equation

Finding Minimal y for Bitwise Equation

Given an integer \(x\), find the smallest positive integer \(y\) such that the following equation holds:

\[ (x \ \operatorname{and} \ y) + (x \ \operatorname{or} \ y) = 2025 \]

Here, \(\operatorname{and}\) denotes the bitwise AND operation and \(\operatorname{or}\) denotes the bitwise OR operation. If no such positive integer \(y\) exists, output \(-1\).

Note: It can be verified that for any two integers \(x\) and \(y\), the identity \((x \ \operatorname{and} \ y) + (x \ \operatorname{or} \ y) = x + y\) holds. Hence, the problem reduces to finding the smallest positive integer \(y\) such that \(x + y = 2025\), meaning \(y = 2025 - x\) when \(2025 - x > 0\).

inputFormat

The input consists of a single integer \(x\).

Format: A single line containing one integer \(x\).

outputFormat

Output the smallest positive integer \(y\) such that \(x + y = 2025\). If no such \(y\) exists (i.e. if \(2025 - x \le 0\)), output \(-1\).

sample

1000
1025