A. Initial Bet
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

The input consists of a single line containing five integers c1, c2, c3, c4 and c5 —
the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0 ≤ c1, c2, c3, c4, c5 ≤ 100).

Output

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).

Sample test(s)
input
2 5 4 0 4
output
3
input
4 5 9 2 1
output
-1
Note

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;
  1. One coin is passed from the fourth player to the second player.

判一下是否为5的倍数,注意特判全为0


代码:
#include <iostream>
#include <cstdio>
using namespace std; int main()
{
int a[10];
int ans=0;
for(int i=0;i<5;i++)
{
scanf("%d",&a[i]);
ans+=a[i];
}
if(ans==0)
{
printf("-1\n");
return 0;
}
if(ans%5==0)
printf("%d\n",ans/5);
else
printf("-1\n");
return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

A. Initial Bet(Codeforces Round #273)的更多相关文章

  1. 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations

    题目传送门 /* 贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr... ans = a[1] + a[2]; 或先2 ...

  2. Codeforces Round #273 (Div. 2)-A. Initial Bet

    http://codeforces.com/contest/478/problem/A A. Initial Bet time limit per test 1 second memory limit ...

  3. Codeforces Round #273 (Div. 2)

    A. Initial Bet 题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况 #include<iostream> #include<cstdio> #incl ...

  4. Codeforces Round #273 (Div. 2) A , B , C 水,数学,贪心

    A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. CODEFORCES ROUND #273 DIV2

    题目大意: A简单的说就是,有五个人,他们刚开始有B元,经过一系列过程后,给你他们现在分别有的钱,让你求出B(> <难得的傻逼题啊...但是要注意B是正整数!特判0) B有n个人,要分成m ...

  6. Codeforces Round #273 (Div. 2)-C. Table Decorations

    http://codeforces.com/contest/478/problem/C C. Table Decorations time limit per test 1 second memory ...

  7. Codeforces Round #273 (Div. 2)-B. Random Teams

    http://codeforces.com/contest/478/problem/B B. Random Teams time limit per test 1 second memory limi ...

  8. C. Table Decorations(Codeforces Round 273)

    C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. B. Random Teams(Codeforces Round 273)

    B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. [半原创]指纹识别+谷歌图片识别技术之C++代码

    原地址:http://blog.csdn.net/guoming0000/article/details/8138223 以前看到一个http://topic.csdn.net/u/20120417/ ...

  2. Linux 核心阅读工具vim+ctags+cscope+taglist

    今天.介绍vim+ctags+cscope+taglist的内核阅读配置. 当使用过之后,我相信大部分人都会舍弃之前的Eclipse(我就是活生生的一个样例).我们先来看看实现的界面是怎么样的: 我们 ...

  3. [linux]ubuntu apt-get安装软件失败

    1.首先查看 dns 配置 sudo vi /etc/resolv.conf nameserver 114.114.114.114 nameserver 8.8.8.8 2.修改 apt-get 源 ...

  4. JSON支持什么对象/类型?

    原文:JSON支持什么对象/类型? 当一个面试官问你: JSON都支持什么对象/类型?你怎么回答? 也许他的本意是下面这个答案: JSON格式支持的数据类型有以下: 类型 描述 Number 在Jav ...

  5. gradle多模块开发(转)

    参考文档:gradle的官方userguide.pdf文档的chapter 55和chapter 56.gradle的多模块或项目开发一定不会比maven差,在我看来!大的项目分成多个模块来开发是常事 ...

  6. Centos 6安装完美搭建mysql、php、apache之旅

    安装apache [root@centos share]# yum -y install httpd Loaded plugins: fastestmirror, refresh-packagekit ...

  7. cocos2d-x-3.1 事件分发机制 (coco2d-x 学习笔记七)

    触摸事件 Sprite* sp1 = Sprite::create("Images/t1.png"); sp1->setPosition(Vec2(visibleSize.w ...

  8. Java对象序列化/反序列化的注意事项

    Java对象序列化 对于一个存在Java虚拟机中的对象来说,其内部的状态只是保存在内存中.JVM退出之后,内存资源也就被释放,Java对象的内部状态也就丢失了.而在很多情况下,对象内部状态是需要被持久 ...

  9. hdu4487(概率dp)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4487 题意:开始位置在0,每一步可以向右向左或者不动,问走了n步后,路径中能到达最右的期望. 分析:d ...

  10. IL来理解属性

    IL来理解属性   阅读目录 概述: C#中如何定义一个属性 Student类 属性Name Main方法 实现get,set方法 性能 访问权限 回到最开始提出的问题 参考资料 .Net底层剖析目录 ...