302526: CF488B. Candy Boxes

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

Description

Candy Boxes

题意翻译

有一个长度为 $4$ 的序列 $a$,满足 $a_1\le a_2\le a_3\le a_4$,并且$\frac{a_2+a_3}{2}=\frac{a_1+a_2+a_3+a_4}{4}=a_4-a_1$ 。 给定 $a$ 中的 $n$ 个数,求一种 $a$ 的构造。 如果存在解,输出``YES``并用任意的顺序给出没有给定的数字。 如果不存在解,输出``NO``。 有多组数据。 by [Error_Eric](https://www.luogu.com.cn/user/217300).

题目描述

There is an old tradition of keeping $ 4 $ boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set $ {x_{1},x_{2},x_{3},x_{4}} $ ( $ x_{1}<=x_{2}<=x_{3}<=x_{4} $ ) arithmetic mean is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/4ced3a9ae4181924c136bcc46ede19844528fdef.png), median is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/2d7e14bfd580007a1d694763c07f2437bb7e66e6.png) and range is $ x_{4}-x_{1} $ . The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs. For example, $ 1,1,3,3 $ is the example of $ 4 $ numbers meeting the condition because their mean, median and range are all equal to $ 2 $ . Jeff has $ 4 $ special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only $ n $ ( $ 0<=n<=4 $ ) boxes remaining. The $ i $ -th remaining box contains $ a_{i} $ candies. Now Jeff wants to know: is there a possible way to find the number of candies of the $ 4-n $ missing boxes, meeting the condition above (the mean, median and range are equal)?

输入输出格式

输入格式


There is an old tradition of keeping $ 4 $ boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set $ {x_{1},x_{2},x_{3},x_{4}} $ ( $ x_{1}<=x_{2}<=x_{3}<=x_{4} $ ) arithmetic mean is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/4ced3a9ae4181924c136bcc46ede19844528fdef.png), median is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/2d7e14bfd580007a1d694763c07f2437bb7e66e6.png) and range is $ x_{4}-x_{1} $ . The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs. For example, $ 1,1,3,3 $ is the example of $ 4 $ numbers meeting the condition because their mean, median and range are all equal to $ 2 $ . Jeff has $ 4 $ special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only $ n $ ( $ 0<=n<=4 $ ) boxes remaining. The $ i $ -th remaining box contains $ a_{i} $ candies. Now Jeff wants to know: is there a possible way to find the number of candies of the $ 4-n $ missing boxes, meeting the condition above (the mean, median and range are equal)?

输出格式


There is an old tradition of keeping $ 4 $ boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set $ {x_{1},x_{2},x_{3},x_{4}} $ ( $ x_{1}<=x_{2}<=x_{3}<=x_{4} $ ) arithmetic mean is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/4ced3a9ae4181924c136bcc46ede19844528fdef.png), median is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF488B/2d7e14bfd580007a1d694763c07f2437bb7e66e6.png) and range is $ x_{4}-x_{1} $ . The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs. For example, $ 1,1,3,3 $ is the example of $ 4 $ numbers meeting the condition because their mean, median and range are all equal to $ 2 $ . Jeff has $ 4 $ special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only $ n $ ( $ 0<=n<=4 $ ) boxes remaining. The $ i $ -th remaining box contains $ a_{i} $ candies. Now Jeff wants to know: is there a possible way to find the number of candies of the $ 4-n $ missing boxes, meeting the condition above (the mean, median and range are equal)?

输入输出样例

输入样例 #1

2
1
1

输出样例 #1

YES
3
3

输入样例 #2

3
1
1
1

输出样例 #2

NO

输入样例 #3

4
1
2
2
3

输出样例 #3

YES

说明

For the first sample, the numbers of candies in $ 4 $ boxes can be $ 1,1,3,3 $ . The arithmetic mean, the median and the range of them are all $ 2 $ . For the second sample, it's impossible to find the missing number of candies. In the third example no box has been lost and numbers satisfy the condition. You may output $ b $ in any order.

Input

题意翻译

有一个长度为 $4$ 的序列 $a$,满足 $a_1\le a_2\le a_3\le a_4$,并且$\frac{a_2+a_3}{2}=\frac{a_1+a_2+a_3+a_4}{4}=a_4-a_1$ 。 给定 $a$ 中的 $n$ 个数,求一种 $a$ 的构造。 如果存在解,输出``YES``并用任意的顺序给出没有给定的数字。 如果不存在解,输出``NO``。 有多组数据。 by [Error_Eric](https://www.luogu.com.cn/user/217300).

加入题单

上一题 下一题 算法标签: