CF478A.Initial Bet

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.

Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.

有五个人在玩一个名为“慷慨”的游戏。每位玩家初始下注一些非零数量的硬币 bb。在所有玩家都下注了 bb 枚硬币后,重复执行以下操作若干次:一枚硬币从一名玩家传递给另一名玩家。

你的任务是编写一个程序,根据游戏结束时每位玩家所拥有的硬币数量,确定初始下注量 bb 的大小;或者判断:对于任意正整数 bb,该最终局面都不可能出现。

输入格式

The input consists of a single line containing five integers _c_1, _c_2, _c_3, _c_4 and _c_5 — the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 ≤ _c_1, _c_2, _c_3, _c_4, _c_5 ≤ 100).

输入包含一行,其中包含五个整数 c1, c2, c3, c4c_1,\,c_2,\,c_3,\,c_4 和 c5c_5 —— 分别表示游戏结束时第一、第二、第三、第四和第五位玩家所拥有的硬币数量(0≤c1, c2, c3, c4, c5≤1000\leq c_1,\,c_2,\,c_3,\,c_4,\,c_5\leq 100)。

输出格式

Print the only line containing a single positive integer b — the number of coins in the initial bet of each player. If there is no such value of b, then print the only value "-1" (quotes for clarity).

输出唯一一行,包含一个正整数 bb —— 即每位玩家初始下注的硬币数量。若不存在满足条件的 bb 值,则输出唯一的值 -1(引号仅用于明确显示)。

输入输出样例

  • 输入#1

    2 5 4 0 4

    输出#1

    3
  • 输入#2

    4 5 9 2 1

    输出#2

    -1

说明/提示

In the first sample the following sequence of operations is possible:

  1. One coin is passed from the fourth player to the second player;
  2. One coin is passed from the fourth player to the fifth player;
  3. One coin is passed from the first player to the third player;
  4. One coin is passed from the fourth player to the second player.

在第一个样例中,可以执行以下操作序列:

  1. 第四名玩家向第二名玩家传递一枚硬币;
  2. 第四名玩家向第五名玩家传递一枚硬币;
  3. 第一名玩家向第三名玩家传递一枚硬币;
  4. 第四名玩家向第二名玩家传递一枚硬币。

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

首页