F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Power Sum

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2738    Accepted Submission(s): 889
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.
 

Sample Input
2 1 5
 

Sample Output
1 1 2 11
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 04:29:12, Gzip enabled