No.688 E869120 and Constructing Array 2
問題文最終更新日: 2026-06-25 06:53:46
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 191
(順位表)
の他の問題:
Problem Statement
Construct a sequence $b$ as described below.
- Choose $0$ or more numbers from $b$. When the length of the sequence is $N$, there are $2^N$ ways to choose.
- There are exactly $K$ ways to choose such that the sum of the chosen numbers is $2$.
- Each $b_i$ must be $0$ or $1$.
- The length $N$ of the sequence must be between $1$ and $30$, inclusive.
Input
K
An integer $K$ between $0$ and $1 \ 000 \ 000 \ 000$, inclusive, is given on one line.
However, it is guaranteed that a sequence satisfying the conditions exists for $K$.
Output
N $b_1, b_2, b_3, ..., b_N$
On the $1$st line, print the length $N$ of the sequence $b$.
On the $2$nd line, print the values of the sequence, separated by spaces.
Print a newline at the end.
Sample
Sample 1
Input
4
Output
4 0 0 1 1
The following $4$ ways of choosing are possible.
- Choose the $3$rd and $4$th elements.
- Choose the $1$st, $3$rd, and $4$th elements.
- Choose the $2$nd, $3$rd, and $4$th elements.
- Choose the $1$st, $2$nd, $3$rd, and $4$th elements.
Sample 2
Input
80
Output
8 0 1 0 1 1 0 1 1
There are exactly $80$ ways of choosing such that the sum is $2$.
Sample 3
Input
96
Output
8 0 1 0 1 1 0 1 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
e869120
はむこ