CF1081E.Missing Numbers
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Chouti is working on a strange math problem.
There was a sequence of n positive integers x1,x2,…,xn , where n is even. The sequence was very special, namely for every integer t from 1 to n , x1+x2+...+xt 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,…,xn . 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.
输入格式
The first line contains an even number n ( 2≤n≤105 ).
The second line contains 2n positive integers x2,x4,…,xn ( 1≤xi≤2⋅105 ).
输出格式
If there are no possible sequence, print "No".
Otherwise, print "Yes" and then n positive integers x1,x2,…,xn ( 1≤xi≤1013 ), where x2,x4,…,xn should be same as in input data. If there are multiple answers, print any.
Note, that the limit for xi 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≤1013 .
输入输出样例
输入#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=4
- x1+x2=9
- x1+x2+x3=25
- x1+x2+x3+x4=36
- x1+x2+x3+x4+x5=100
- x1+x2+x3+x4+x5+x6=144
All these numbers are perfect squares.In the second example, x1=100 , x1+x2=10000 . They are all perfect squares. There're other answers possible. For example, x1=22500 is another answer.
In the third example, it is possible to show, that no such sequence exists.