No.638 Sum of "not power of 2"
タグ : / 解いたユーザー数 260
作問者 :
WA_TLE
Problem Statement
You are given a positive integer $N$. Determine whether it can be expressed in the form $N = a + b$ (where $a, b$ are positive integers that cannot be expressed as an integer power of $2$), and if it can, find the pair $(a, b)$ that minimizes $a$.
Input
N
On line 1, an integer $N (1 \le N \le 10^{18})$ is given.
Output
If it can be expressed, print $a, b$ separated by a space in 1 line.
If it cannot be expressed, print -1.
In either case, end the output with a newline.
Sample
Sample 1
Input
5
Output
-1
Written as a sum of two positive integers, $5$ is one of $1 + 4, 2 + 3, 3 + 2, 4 + 1$, but each of these contains a number that can be expressed as an integer power of $2$.
Sample 2
Input
11
Output
5 6
$(a, b) = (5, 6), (6, 5)$ satisfy the conditions. The one with the smaller $a$ is $(a, b) = (5, 6)$, so print this.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。