CF1081E.Missing Numbers

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Chouti is working on a strange math problem.

There was a sequence of nn positive integers x1,x2,…,xnx_1, x_2, \ldots, x_n, where nn is even. The sequence was very special, namely for every integer tt from 11 to nn, x1+x2+...+xtx_1+x_2+...+x_t is a square of some integer number (that is, a perfect square).

Somehow, the numbers with odd indexes turned to be missing, so he is only aware of numbers on even positions, i.e. x2,x4,x6,…,xnx_2, x_4, x_6, \ldots, x_n. The task for him is to restore the original sequence. Again, it's your turn to help him.

The problem setter might make mistakes, so there can be no possible sequence at all. If there are several possible sequences, you can output any.

Chouti 正在解决一个奇怪的数学问题。

存在一个由 nn 个正整数组成的序列 x1,x2,…,xnx_1, x_2, \ldots, x_n,其中 nn 为偶数。该序列非常特殊:对每个从 11 到 nn 的整数 tt,前 tt 项和 x1+x2+⋯+xtx_1+x_2+\cdots+x_t 均为某个整数的平方(即一个完全平方数)。

不知何故,所有奇数下标位置上的数字丢失了,因此他只知道偶数位置上的数字,即 x2,x4,x6,…,xnx_2, x_4, x_6, \ldots, x_n。他的任务是还原原始序列。现在轮到你来帮助他。

题目出题人可能犯错,因此可能根本不存在满足条件的序列。若存在多个可能的序列,输出任意一个即可。

输入格式

The first line contains an even number nn (2≤n≤1052 \le n \le 10^5).

The second line contains n2\frac{n}{2} positive integers x2,x4,…,xnx_2, x_4, \ldots, x_n (1≤xi≤2⋅1051 \le x_i \le 2 \cdot 10^5).

第一行包含一个偶数 nn(2≤n≤1052 \le n \le 10^5)。

第二行包含 n2\frac{n}{2} 个正整数 x2,x4,…,xnx_2, x_4, \ldots, x_n(1≤xi≤2⋅1051 \le x_i \le 2 \cdot 10^5)。

输出格式

If there are no possible sequence, print "No".

Otherwise, print "Yes" and then nn positive integers x1,x2,…,xnx_1, x_2, \ldots, x_n (1≤xi≤10131 \le x_i \le 10^{13}), where x2,x4,…,xnx_2, x_4, \ldots, x_n should be same as in input data. If there are multiple answers, print any.

Note, that the limit for xix_i is larger than for input data. It can be proved that in case there is an answer, there must be a possible sequence satisfying 1≤xi≤10131 \le x_i \le 10^{13}.

如果不存在可能的序列,输出“No”。

否则,输出“Yes”,然后输出 nn 个正整数 x1,x2,…,xnx_1, x_2, \ldots, x_n(满足 1≤xi≤10131 \le x_i \le 10^{13}),其中 x2,x4,…,xnx_2, x_4, \ldots, x_n 必须与输入数据中的对应值完全相同。若存在多个答案,输出任意一个即可。

注意:xix_i 的上限比输入数据的上限更大。可以证明,当存在解时,必然存在一个满足 1≤xi≤10131 \le x_i \le 10^{13} 的可行序列。

输入输出样例

  • 输入#1

    6
    5 11 44

    输出#1

    Yes
    4 5 16 11 64 44
  • 输入#2

    2
    9900

    输出#2

    Yes
    100 9900
  • 输入#3

    6
    314 1592 6535

    输出#3

    No

说明/提示

In the first example

  • x1=4x_1=4
  • x1+x2=9x_1+x_2=9
  • x1+x2+x3=25x_1+x_2+x_3=25
  • x1+x2+x3+x4=36x_1+x_2+x_3+x_4=36
  • x1+x2+x3+x4+x5=100x_1+x_2+x_3+x_4+x_5=100
  • x1+x2+x3+x4+x5+x6=144x_1+x_2+x_3+x_4+x_5+x_6=144

All these numbers are perfect squares.

In the second example, x1=100x_1=100, x1+x2=10000x_1+x_2=10000. They are all perfect squares. There're other answers possible. For example, x1=22500x_1=22500 is another answer.

In the third example, it is possible to show, that no such sequence exists.

在第一个例子中:

  • x1=4x_1=4
  • x1+x2=9x_1+x_2=9
  • x1+x2+x3=25x_1+x_2+x_3=25
  • x1+x2+x3+x4=36x_1+x_2+x_3+x_4=36
  • x1+x2+x3+x4+x5=100x_1+x_2+x_3+x_4+x_5=100
  • x1+x2+x3+x4+x5+x6=144x_1+x_2+x_3+x_4+x_5+x_6=144

所有这些数均为完全平方数。

在第二个例子中,x1=100x_1=100,x1+x2=10000x_1+x_2=10000,它们均为完全平方数。还存在其他可能的答案。例如,x1=22500x_1=22500 是另一个答案。

在第三个例子中,可以证明:不存在满足条件的序列。

输入解题思路,AI测评打分。不知道怎么写?

首页