Codeforces Beta Round 39
D
有趣的序列
Interesting Sequence
Codeforces
2600
原题
← CE →

有趣的序列AI (CI翻译)

Berland scientists noticed long ago that the world around them depends on Berland population. Due to persistent research in this area the scientists managed to find out that the Berland chronology starts from the moment when the first two people came to that land (it is considered to have happened in the first year). After one Berland year after the start of the chronology the population had already equaled 13 people (the second year). However, tracing the population number during the following years was an ultimately difficult task, still it was found out that if $*d*_{*i*}$ — the number of people in Berland in the year of $*i*$, then either $*d*_{*i*} = 12*d*_{*i* - 2}$, or $*d*_{*i*} = 13*d*_{*i* - 1} - 12*d*_{*i* - 2}$. Of course no one knows how many people are living in Berland at the moment, but now we can tell if there could possibly be a year in which the country population equaled $*A*$. That's what we ask you to determine. Also, if possible, you have to find out in which years it could be (from the beginning of Berland chronology). Let's suppose that it could be in the years of $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$. Then you have to define how many residents could be in the country during those years apart from the $*A*$ variant. Look at the examples for further explanation.

很久以前,Berland 的科学家就注意到,他们周围的世界取决于 Berland 的人口。经过这方面持续不断的研究,科学家们发现,Berland 的编年史始于最初两个人来到这片土地的时刻(这被认为发生在第一年)。编年史开始后的一个 Berland 年,人口已经达到 13 人(即第二年)。然而,追踪之后各年的人口数量是一项极其困难的任务。不过,他们还是发现:如果 $*d*_{*i*}$ 表示 Berland 在第 $*i*$ 年的人口,那么要么有 $*d*_{*i*} = 12*d*_{*i* - 2}$,要么有 $*d*_{*i*} = 13*d*_{*i* - 1} - 12*d*_{*i* - 2}$。当然,没有人知道目前 Berland 有多少人口,但现在我们可以判断,是否可能存在某一年,该国人口恰好为 $A$。这正是需要你确定的内容。此外,如果可能,还需要找出从 Berland 编年史开始算起,哪些年份可能出现这种情况。假设它可能发生在第 $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$ 年。那么,除人口为 $A$ 的情况外,你还需要确定在这些年份中该国人口可能是多少。请参见样例以进一步了解。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains integer $*A*$ ($1 ≤ *A* < 10^{300}$). It is guaranteed that the number doesn't contain leading zeros.

第一行包含一个整数 $*A*$($1 ≤ *A* < 10^{300}$)。保证该数字不含前导零。AI (CI翻译)

Output

输出格式

AI (CI翻译)

On the first output line print YES, if there could be a year in which the total population of the country equaled $*A*$, otherwise print NO.

在第一行输出 YES,如果可能存在某一年该国总人口恰好等于 $*A*$;否则输出 NO。AI (CI翻译)

If the answer is YES, then you also have to print number $*k*$ — the number of years in which the population could equal $*A*$. On the next line you have to output precisely $*k*$ space-separated numbers — $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$. Those numbers have to be output in the increasing order.

如果答案为 YES,还要输出数字 $*k*$,即人口可能等于 $*A*$ 的年份数。下一行输出恰好 $*k*$ 个以空格分隔的数字——$*a*_{1}, *a*_{2}, ..., *a*_{*k*}$。这些数字必须按递增顺序输出。AI (CI翻译)

On the next line you should output number $*p*$ — how many variants of the number of people could be in the years of $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$, apart from the $*A*$ variant. On each of the next $*p*$ lines you have to print one number — the sought number of residents. Those number also have to go in the increasing order.

下一行输出数字 $*p*$,表示在第 $*a*_{1}, *a*_{2}, ..., *a*_{*k*}$ 年中,除人口为 $*A*$ 外,人口数还可能有多少种。接下来的 $*p*$ 行中,每行输出一个数字,即所求的人口数。这些数字也必须按递增顺序输出。AI (CI翻译)

If any number (or both of them) $*k*$ or $*p*$ exceeds $1000$, then you have to print $1000$ instead of it and only the first $1000$ possible answers in the increasing order.

如果 $*k*$ 或 $*p*$ 中任意一个(或两个)超过 1000,则将对应的数字输出为 1000,并且只输出按递增顺序排列的前 1000 个可能答案。AI (CI翻译)

The numbers should have no leading zeros.

所有数字都不能包含前导零。AI (CI翻译)

样例

Input #1
2
Output #1
YES
1
1
0
InputCopy OutputCopy
Input #2
3
Output #2
NO
InputCopy OutputCopy
Input #3
13
Output #3
YES
1
2
0
InputCopy OutputCopy
Input #4
1729
Output #4
YES
1
4
1
156
InputCopy OutputCopy
题目信息
题号
40D
时间限制
3 s
内存限制
256 MB
标签
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。