CodeforcesRound#278(Div.2)B??CandyBoxes_html/css_WEB-ITnose
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CodeforcesRound#278(Div.2)B??CandyBoxes_html/css_WEB-ITnose,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6540字,纯文字阅读大概需要10分钟。
内容图文
![CodeforcesRound#278(Div.2)B??CandyBoxes_html/css_WEB-ITnose](/upload/InfoBanner/zyjiaocheng/400/81429d8a2c3b4dd08bf938e4a7d804c4.jpg)
B. Candy Boxes
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 {x1,?x2,?x3,?x4} (x1?≤?x2?≤?x3?≤?x4) arithmetic mean is , median is and range is x4?-?x1. 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 ai 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)?
Input
The first line of input contains an only integer n (0?≤?n?≤?4).
The next n lines contain integers ai, denoting the number of candies in the i-th box (1?≤?ai?≤?500).
Output
In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution.
If a solution exists, you should output 4?-?n more lines, each line containing an integer b, denoting the number of candies in a missing box.
All your numbers b must satisfy inequality 1?≤?b?≤?106. It is guaranteed that if there exists a positive integer solution, you can always find such b's meeting the condition. If there are multiple answers, you are allowed to print any of them.
Given numbers ai may follow in any order in the input, not necessary in non-decreasing.
ai may have stood at any positions in the original set, not necessary on lowest n first positions.
Sample test(s)
Input
211
Output
YES33
Input
3111
Output
NO
Input
41223
Output
YES
很麻烦的一题啊,需要分别考虑0,1,2,3,4个数的情况
#include
内容总结
以上是互联网集市为您收集整理的CodeforcesRound#278(Div.2)B??CandyBoxes_html/css_WEB-ITnose全部内容,希望文章能够帮你解决CodeforcesRound#278(Div.2)B??CandyBoxes_html/css_WEB-ITnose所遇到的程序开发问题。
如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
来源:【匿名】