Power Sum

TimeLimit:1000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
Special Judge
未提交 | 登录后收藏
Problem Description
Given a positive number $n$, Kris needs to find a positive number $k$ and an array $\{a_i\}(a_i\in\{-1,1\})$ of length $k(1\le k\le n + 2)$, such that:

$$
\sum\limits_{i=1}^k a_i\times i^2 = n
$$

This is too hard for Kris so you have to help him.
Input
The input contains multiple test cases.

The first line contains an integer $T(1 \leq T \leq 100)$ indicating the number of test cases.

Each of the next $T$ lines contains one integer $n(1 \leq n \leq 10 ^ 6)$.

It's guaranteed that $\sum{n} \leq 3 * 10 ^ 7$.
Output
The output should contain $2T$ lines. For each test case, output two lines.

The first line contains one integer, $k$.

The second line contains a 01-string of length $k$ representing the array, with 0 in the $i$th position denoting $a_i=-1$ and 1 denoting $a_i=1$.

If there are multiple answers, print any.
SampleInput
2
1
5
SampleOutput
1
1
2
11
Submit
题目统计信息详细
总AC数8
通过人数6
尝试人数7
总提交量16
AC率37.50%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: