A8545 | Problem About Equation
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A group of $n$ merry programmers celebrate Robert Floyd's birthday. Polucarpus has got an honourable task of pouring Ber-Cola to everybody. Pouring the same amount of Ber-Cola to everybody is really important. In other words, the drink's volume in each of the $n$ mugs must be the same.
Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has $a_{1}$ milliliters of the drink, the second one has $a_{2}$ milliliters and so on. The bottle has $b$ milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.
Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously:
- there were $b$ milliliters poured in total. That is, the bottle need to be emptied;
- after the process is over, the volumes of the drink in the mugs should be equal.
Polycarpus has already began the process and he partially emptied the Ber-Cola bottle. Now the first mug has $a_{1}$ milliliters of the drink, the second one has $a_{2}$ milliliters and so on. The bottle has $b$ milliliters left and Polycarpus plans to pour them into the mugs so that the main equation was fulfilled.
Write a program that would determine what volume of the drink Polycarpus needs to add into each mug to ensure that the following two conditions were fulfilled simultaneously:
- there were $b$ milliliters poured in total. That is, the bottle need to be emptied;
- after the process is over, the volumes of the drink in the mugs should be equal.
输入格式
The first line contains a pair of integers $n$ , $b$ ( $2<=n<=100,1<=b<=100$ ), where $n$ is the total number of friends in the group and $b$ is the current volume of drink in the bottle. The second line contains a sequence of integers $a_{1},a_{2},...,a_{n}$ ( $0<=a_{i}<=100$ ), where $a_{i}$ is the current volume of drink in the $i$ -th mug.
输出格式
Print a single number "-1" (without the quotes), if there is no solution. Otherwise, print $n$ float numbers $c_{1},c_{2},...,c_{n}$ , where $c_{i}$ is the volume of the drink to add in the $i$ -th mug. Print the numbers with no less than 6 digits after the decimal point, print each $c_{i}$ on a single line. Polycarpus proved that if a solution exists then it is unique.
Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma.
Russian locale is installed by default on the testing computer. Make sure that your solution use the point to separate the integer part of a real number from the decimal, not a comma.
输入输出样例
输入 #1
5 50 1 2 3 4 5
输出 #1
12.000000 11.000000 10.000000 9.000000 8.000000
输入 #2
2 2 1 100
输出 #2
-1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted