CF174A.Problem About Equation

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

一群共 nn 位快乐的程序员正在庆祝罗伯特·弗洛伊德(Robert Floyd)的生日。波吕卡普斯(Polycarpus)肩负着一项光荣的任务:为所有人倒“伯可乐”(Ber-Cola)。为每个人倒入等量的伯可乐至关重要。换言之,nn 个杯子中每只杯子里的饮料体积必须完全相同。

波吕卡普斯已经开始了倒酒过程,并已将伯可乐瓶子部分倒空。目前,第一个杯子中有 a1a_1 毫升饮料,第二个杯子中有 a2a_2 毫升,依此类推。瓶中还剩余 bb 毫升饮料,波吕卡普斯计划将这剩余的 bb 毫升全部倒入各杯子中,以满足上述“等量”要求。

请编写一个程序,计算出波吕卡普斯需向每个杯子中分别加入多少毫升饮料,使得以下两个条件同时满足:

  • 总共恰好倒入 bb 毫升饮料,即瓶子必须被完全倒空;
  • 倒完后,所有杯子中的饮料体积完全相等。

输入格式

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.

第一行包含一对整数 nn、bb(2 ≤ n ≤ 1002 \leq n \leq 100,1 ≤ b ≤ 1001 \leq b \leq 100),其中 nn 表示组内朋友的总人数,bb 表示瓶中当前的饮料体积。
第二行包含一个整数序列 a1, a2, ..., ana_1,\,a_2,\,...,\,a_n(0 ≤ ai ≤ 1000 \leq a_i \leq 100),其中 aia_i 表示第 ii 个杯子中当前的饮料体积。

输出格式

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.

如果无解,输出单个数字 -1(不带引号)。否则,输出 nn 个浮点数 c1, c2, ..., cnc_1,\,c_2,\,...,\,c_n,其中 cic_i 表示需加入第 ii 个杯子中的饮料体积。每个 cic_i 至少保留小数点后 6 位,且每个 cic_i 单独占一行。波利卡普斯已证明:若解存在,则该解唯一。

评测机默认安装俄语区域设置。请确保您的程序使用英文小数点(即“.”)分隔实数的整数部分与小数部分,而非逗号(“,”)。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页