CF40D.Interesting Sequence
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
伯兰科学家很早就发现,他们周围的世界取决于伯兰的人口数量。经过长期深入研究,科学家们发现:伯兰纪年始于最初两个人抵达这片土地之时(此事件被认为发生在第一年)。纪年开始一年后(即第二年),人口数量已达到 13 人。然而,在随后的年份中追踪人口数量是一项极其困难的任务;尽管如此,科学家们仍发现:若记第 i 年伯兰的人口数为 di,则必有
di=12di−2或di=13di−1−12di−2.
当然,目前无人知晓伯兰当前确切的人口数量。但如今我们能够判断:是否存在某一年,使得该国人口恰好等于给定值 A?这正是本题要求你判定的问题。若存在这样的年份,请找出所有可能的年份(从伯兰纪年开始算起)。假设这些可能的年份为 a1,a2,…,ak,那么你还需确定:在这些年份中,除 A 外,还可能存在哪些其他人口数量?请参阅样例以获得进一步说明。
输入格式
The first line contains integer A (1 ≤ A < 10300). It is guaranteed that the number doesn't contain leading zeros.
第一行包含一个整数 A(1 ≤ A < 10300)。保证该数字不包含前导零。
输出格式
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.
在第一行输出中,如果存在某一年使得该国总人口恰好等于 A,则输出 YES,否则输出 NO。
若答案为 YES,则还需输出一个整数 k —— 即人口可能等于 A 的年份数量。紧接着下一行需恰好输出 k 个以空格分隔的整数:a1, a2, …, ak,这些数须按升序排列。
再下一行应输出整数 p —— 表示在年份 a1, a2, …, ak 中,除 A 外,人口数量还可能取多少种不同的值。随后的 p 行中,每行输出一个所求的人口数值,这些数值也须按升序排列。
若 k 或 p(或二者)超过 1000,则应输出 1000,并且仅输出前 1000 个可能的答案(按升序)。
所有数字均不得有前导零。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?