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
  1. 2 5 4 0 4
output
  1. 3
input
  1. 4 5 9 2 1
output
  1. -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;
  4. One coin is passed from the fourth player to the second player.

div2A的sb题

读入5个数,如果平均数除五除不尽或者平均数是0就输出-1,否则输出平均数

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cstring>
  4. #include<cstdlib>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<queue>
  8. #include<deque>
  9. #include<set>
  10. #include<map>
  11. #include<ctime>
  12. #define LL long long
  13. #define inf 0x7ffffff
  14. #define pa pair<int,int>
  15. #define pi 3.1415926535897932384626433832795028841971
  16. using namespace std;
  17. inline LL read()
  18. {
  19. LL x=,f=;char ch=getchar();
  20. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  21. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  22. return x*f;
  23. }
  24. int a,b,c,d,e,f;
  25. int main()
  26. {
  27. a=read();b=read();c=read();d=read();e=read();
  28. f=a+b+c+d+e;
  29. if(f%!=||f/==)
  30. {
  31. printf("-1");
  32. return ;
  33. }else printf("%d",f/);
  34. }

cf478A

cf478A Initial Bet的更多相关文章

  1. A. Initial Bet(Codeforces Round #273)

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

  2. 【CODEFORCES】 A. Initial Bet

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

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

  4. codeforces 478A.Initial Bet 解题报告

    题目链接:http://codeforces.com/problemset/problem/478/A 题目意思:简单来说,就是初始化的时候,五个人的值都是 b,现在给出每个人最终的状态:就是经过互相 ...

  5. Codeforces Round #273 (Div. 2)

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

  6. cf Round#273 Div.2

    题目链接,点击一下 Round#273 Div.2 ================== problem A Initial Bet ================== 很简单,打了两三场的cf第一 ...

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

  8. Tempdb initial size和dbcc shrinkfile

    在使用sql server时您可能遇到过下面的情况,tempdb的数据文件初始大小为3mb, 随着对tempdb的使用,tempdb文件逐渐变得很大(例如30GB),导致了磁盘空间不足. 此时您需要立 ...

  9. INITIAL参数设置导致TRUNCATE TABLE不能降低高水位线案例

    在一个数据库使用下面SQL找出了一批需要降低高水位线的表,其中有几个表没有数据,于是我打算用TRUNCATE来降低高水位线HWM SELECT a.owner,        a.segment_na ...

随机推荐

  1. Array vs Linked List

    Access: Random / Sequential 1. Array element can be randomly accessed using index 2. Random access f ...

  2. Micro Python - Python for microcontrollers

    Micro Python - Python for microcontrollers MicroPython

  3. php随机函数

    <?php function generate_password( $length = 6 ) { // 密码字符集,可任意添加你需要的字符 // $chars = 'abcdefghijklm ...

  4. 归纳下js面向对象的几种常见写法

    //定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area() 1.工厂方式 var Circle = function() { var obj = new Object(); ob ...

  5. 修改UITextField placeholder Color

    [YourtextField setValue:[UIColor colorWithRed:97.0/255.0 green:1.0/255.0 blue:17.0/255.0 alpha:1.0] ...

  6. Java动态 遍历List 时删除List特征元素 异常问题 及解决方案总结

    首先.这是一个极其简单的问题,大牛可忽略.新手可能会遇到,Java中遍历某个List 时删除该List元素 会抛出异常. 这一个简单的问题再高手严重不值一提,但新手可能会比較困惑,用哪种方式能够安全有 ...

  7. pat 1049 Counting Ones

    要统计1到N之间‘1’的个数,如数11包含2个1.所以当N=12时,答案为5. 思想: 找规律,假设ans[N]表示1到N的‘1’的个数,则有a[100]=(a[10]-1)*9+10+a[10]-1 ...

  8. 阿里云部署Docker(5)----管理和公布您的镜像

    出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...

  9. maven ClassNotFoundException: org.springframework.web.context.ContextLoader

    信息: Starting Servlet Engine: Apache Tomcat/6.0.32 2012-3-31 9:39:40 org.apache.catalina.core.Standar ...

  10. [J2EE框架][Debug]

    注意xml头部问题 比如在xx-servlet中注意: <mvc:annotation-driven/> <context:component-scan base-package=& ...