当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7231:The Dark Temple

题目描述
$\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$.
输入解释
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.
输出解释
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$.
输入样例
2
4
22
输出样例
-1
11 3
1 2 4 4

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7231

最后修改于 2022-09-15T06:17:31+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)