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

The Dark Temple

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 65    Accepted Submission(s): 25


Problem Description
$\space \space$*“We do not all have to enter the darkness to fight against it."*

$\space \space$*"Sometimes, defeating evil means getting your hands dirty."*



$\space \space$*"And sometimes, getting your hands dirty turns you to evil." Ishanah's smile seemed mocking.*



$\space \space$*"In order to work with the Light, you must be pure of heart."*

$\space \space$*"And you think I am not?" Maiev's anger simmered in her voice.*

$\space \space$*"I think you do what you believe is right.”*

Illidan is practicing light magic now and he is trying to use holy light to make a good tree.

A good tree is a rooted tree and each vertex of it is either a leaf or has two children.

And he wants the sum of the depth of each vertex in the tree to be a certain number. The depth of a vertex is the length of the path to its root.

The "depth sequence" $A$ of tree T, is an infinite sequence where $A[i] = f(T,i)$. $f(T, i)$ is the number of vertices in the tree $T$ with depth $i$.

Given an integer $k$, you should determine whether there is a good tree $T$ such that, $$\sum_{i\geq 0}f(T,i) * i = k$$

If there is no such tree, output -1.

If there are more than one eligible trees, please output the one with the minimum number of vertices.

If there are still more than one eligible trees, please output the one with the lexicographically smallest depth sequence.

In this problem, for your convenience, you only need to output the depth sequence of the tree.

It can be proven that the output is uniquely determined.

Note: For two infinite sequences $A$ and $B$, $A$ is less than $B$ in lexicographical order if and only if there exists $i \geq 0$ such that $A[i] < B[i]$, and $A[j] =B[j]$ for all $j =0..i-1$.
 

Input
The input consists of multiple test cases.

The first line contains one integer $T\ (1\leq T\leq 10)$ denoting the number of test cases.

The following are $T$ test cases.

Each test case consists of one line containing one integer $k\ (0\leq k\leq 10^{12})$, which is the sum of depth of all vertices.
 

Output
For each test case, if there is no such tree, output one line containing $-1$.

Otherwise, output two lines.

The first line contains two numbers $n$ and $d$ indicating the number of vertices and the maximal depth of vertices in the tree.

The second line contains $d + 1$ numbers indicating $A[0]..A[d]$ that is the positive part of the degree sequence $A$.
 

Sample Input
2 4 22
 

Sample Output
-1 11 3 1 2 4 4
 

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:48:38, Gzip enabled