"In another time,
I would be your friend.
We would run in the silly room,
and then play until the end.
In another time,
I would not get banned.
So I don't have to say to you,
about that I am an error."
—— Yunyan's diary 580 years ago
Yunyan is a bug product from the deepest layer of the Abyss in one Abyss Cycle. He wants to control the universe and replace Tianjiang. He found that the Blue Planet enjoys the greatest sources of magic power. So he utilized the errors in the Abyss to revamp a portal leading to the Blue Planet. But his own power wasn't strong at first, so he needed to take advantage of other people.
In Yunyan's first attempt, he found Hefeng by chance and invited she to the Blue Planet. It was at that time that Yunyan, a pure bug, has formed the emotions. He was deeply touched by the kindness of Hefeng and they became best friends. Yunyan once had a happy time. But every day is not Sunday, Tianjiang came back from the frontier trip and fixed the errors. Soon Yunyan's power was depleted. In the last moment before his death, he used the Abyss Chronosphere and returned to the previous time.
Then in the next attempts, he decided to fight against Tianjiang but all failed. After countless times of retry and time transporting, something unpredictable happened——when Yunyan returned to the previous time again, he shockly found that the Abyss Chronosphere is missing. Having no choice, Yunyan decided to take the final attempt.
Before Yunyan started his plans, he wrote his last diary, or testament on the Abyss Log that would not be changed eternally even if Yunyan go back to the past.
The diary is protected by an digital lock. The lock has m switches, and an puzzle number x . Here're the details:
Given constants x ( x is an odd number), m and m unknown numbers a_0,a_1,\cdots ,a_{m-1} satisfying \forall i\in[0,m-1],a_i=\pm 1 . The equation goes below: x=a_0\cdot2^0+a_1\cdot 2^1+a_2\cdot 2^2+\cdots+a_{m-1}\cdot2^{m-1} You need to figure out all the unknown numbers a_0,a_1,\cdots,a_{m-1} . It can be proven that if the solution exists, it has and only has one solution.
输入
Input two integers x,m(-10^9+1\le x\le10^9-1,|x|\bmod2=1,1\le m\le30) .
输出
If the solution exists, output m integers, the i-th integer is a_{i-1}(a_{i-1}=-1 or a_{i-1}=1) . If the solution is not exist, output 0
.
样例
标准输入 复制文本 |
5 3 |
标准输出 复制文本 |
-1 1 1 |
标准输入 复制文本 |
-9 3 |
标准输出 复制文本 |
0 |
标准输入 复制文本 |
1437581 28 |
标准输出 复制文本 |
-1 1 1 -1 -1 -1 1 1 1 1 1 -1 1 1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 |
提示
In the first example, the only solution is 5=(-1)\cdot2^0+1\cdot2^1+1\cdot 2^2
In the second example, there's no solution.
来源
2022 软件学院 ACM 集训队筛选赛