A9740 | Candy Boxes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 , median is  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)?
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 , median is  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)?
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 , median is  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)?
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted