No.2608 Divide into two
Problem Statement
Divide the numbers from $1$ to $N$ into $2$ groups so that their sums are equal.
You are given a positive integer $N$. Consider painting each of the $N$ numbers from $1$ to $N$ with $1$ color, either blue or red.
Determine whether there exists a way of painting such that the sum of the numbers painted blue equals the sum of the numbers painted red, and if one exists, show one example.
You are given $T$ test cases, so find the answer for each of them.
Input
The $1$st line of the input is as follows.$T$Then, $T$ test cases follow. Each of them is given in the following format.
$N$
- $1 \leq T \leq 100$
- $1 \leq N \leq 100$
- All inputs are integers.
Output
If no way of painting satisfying the condition exists, print -1 followed by a newline.
If one exists, print a string of $N$ characters consisting of 0 and 1, followed by a newline. Here, the $i$-th character from the left being 0 means that $i$ is painted blue, and 1 means that $i$ is painted red.
Sample
Sample 1
Input
3
1
3
8
Output
-1
110
00100011
- For the $1$st test case, no way of painting satisfies the condition.
- For the $2$nd test case, the sum of the numbers painted blue is $3$, and the sum of the numbers painted red is $3 = 1+2$.
- For the $3$rd test case, the sum of the numbers painted blue is $18 = 1+2+4+5+6$, and the sum of the numbers painted red is $18 = 3+7+8$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂