300199: CF40D. Interesting Sequence

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Interesting Sequence

题意翻译

#### 题目描述: 你有一个数列 $A$。开始时 $A_1=2,A_2=13$。已知:$\forall i$ 有 $d_i=12 \times d_{i-2}$ 或者 $d_i=13\times d_{i-1}-12\times d_{i-2}$。输入一个数 $x$,判断 $x$ 是否在该数列中。 #### 输入格式: 一个数 $x$($1 \leq x < 10^{300}$)。 #### 输出格式: 第一行:如果 $x$ 在数列 A 中,输出 `YES`,否则输出 `NO`。 如果第一行输出的是 `YES`,第二行输出一个整数 $k$ 表示有多少项的值可能为 $x$,第三行 $k$ 个数 $a_1,a_2......a_k$ 表示第 $a_i$ 项可能为 $x$。 第四行一个整数 $p$ 表示第 $a_1,a_2,a_3......a_k$ 共有其他 $p$ 种可能的值(除 $x$ 之外)。第五行 $p$ 个整数,表示所有其他可能的值。 如果 $k$ 或者 $p$ 超过 1000 项,只需输出 1000 和前 1000 项。 输出的第三行和第五行必须为不降序,且不应该有前导零。

题目描述

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}=12d_{i-2} $ , or $ d_{i}=13d_{i-1}-12d_{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.

输入输出格式

输入格式


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

输出格式


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. 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. 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. 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. The numbers should have no leading zeros.

输入输出样例

输入样例 #1

2

输出样例 #1

YES
1
1
0

输入样例 #2

3

输出样例 #2

NO

输入样例 #3

13

输出样例 #3

YES
1
2
0

输入样例 #4

1729

输出样例 #4

YES
1
4
1
156

Input

题意翻译

#### 题目描述: 你有一个数列 $A$。开始时 $A_1=2,A_2=13$。已知:$\forall i$ 有 $d_i=12 \times d_{i-2}$ 或者 $d_i=13\times d_{i-1}-12\times d_{i-2}$。输入一个数 $x$,判断 $x$ 是否在该数列中。 #### 输入格式: 一个数 $x$($1 \leq x < 10^{300}$)。 #### 输出格式: 第一行:如果 $x$ 在数列 A 中,输出 `YES`,否则输出 `NO`。 如果第一行输出的是 `YES`,第二行输出一个整数 $k$ 表示有多少项的值可能为 $x$,第三行 $k$ 个数 $a_1,a_2......a_k$ 表示第 $a_i$ 项可能为 $x$。 第四行一个整数 $p$ 表示第 $a_1,a_2,a_3......a_k$ 共有其他 $p$ 种可能的值(除 $x$ 之外)。第五行 $p$ 个整数,表示所有其他可能的值。 如果 $k$ 或者 $p$ 超过 1000 项,只需输出 1000 和前 1000 项。 输出的第三行和第五行必须为不降序,且不应该有前导零。

加入题单

算法标签: