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

题解:加起来看能不能除5除的尽即可。

注意sum==0的时候也要输出-1。

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

【CODEFORCES】 A. Initial Bet的更多相关文章

  1. 【Codeforces】Round #491 (Div. 2) 总结

    [Codeforces]Round #491 (Div. 2) 总结 这次尴尬了,D题fst,E没有做出来.... 不过还好,rating只掉了30,总体来说比较不稳,下次加油 A:If at fir ...

  2. 【Codeforces】Round #488 (Div. 2) 总结

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...

  3. 【CodeForces】601 D. Acyclic Organic Compounds

    [题目]D. Acyclic Organic Compounds [题意]给定一棵带点权树,每个点有一个字符,定义一个结点的字符串数为往下延伸能得到的不重复字符串数,求min(点权+字符串数),n&l ...

  4. 【Codeforces】849D. Rooter's Song

    [算法]模拟 [题意]http://codeforces.com/contest/849/problem/D 给定n个点从x轴或y轴的位置p时间t出发,相遇后按对方路径走,问每个数字撞到墙的位置.(还 ...

  5. 【CodeForces】983 E. NN country 树上倍增+二维数点

    [题目]E. NN country [题意]给定n个点的树和m条链,q次询问一条链(a,b)最少被多少条给定的链覆盖.\(n,m,q \leq 2*10^5\). [算法]树上倍增+二维数点(树状数组 ...

  6. 【CodeForces】925 C.Big Secret 异或

    [题目]C.Big Secret [题意]给定数组b,求重排列b数组使其前缀异或和数组a单调递增.\(n \leq 10^5,1 \leq b_i \leq 2^{60}\). [算法]异或 为了拆位 ...

  7. 【CodeForces】700 D. Huffman Coding on Segment 哈夫曼树+莫队+分块

    [题目]D. Huffman Coding on Segment [题意]给定n个数字,m次询问区间[l,r]的数字的哈夫曼编码总长.1<=n,m,ai<=10^5. [算法]哈夫曼树+莫 ...

  8. 【CodeForces】906 D. Power Tower 扩展欧拉定理

    [题目]D. Power Tower [题意]给定长度为n的正整数序列和模数m,q次询问区间[l,r]累乘幂%m的答案.n,q<=10^5,m,ai<=10^9. [算法]扩展欧拉定理 [ ...

  9. 【CodeForces】741 D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(dsu on tree)

    [题意]给定n个点的树,每条边有一个小写字母a~v,求每棵子树内的最长回文路径,回文路径定义为路径上所有字母存在一种排列为回文串.n<=5*10^5. [算法]dsu on tree [题解]这 ...

随机推荐

  1. H. Fake News (medium)

    H. Fake News (medium) 题意 以前是给出 S T 串,问在 S 中有多少个子串为 T 的个数,子串可以不连续,保持位置相对一致. 现在给出 n ,要你构造 S T 串. 分析 这种 ...

  2. 树链剖分【p1505】[国家集训队]旅游

    Description Ray 乐忠于旅游,这次他来到了T 城.T 城是一个水上城市,一共有 N 个景点,有些景点之间会用一座桥连接.为了方便游客到达每个景点但又为了节约成本,T 城的任意两个景点之间 ...

  3. 数学【p2613】 【模板】有理数取余(费马小定理)

    题目描述 给出一个有理数 c=a/b ,求 c mod 19260817的值. 说明 对于所有数据, 0≤a,b≤10^10001 分析: 一看题 这么短 哇简单!况且19260817还是个素数!(美 ...

  4. luogu P1577 切绳子

    题目描述 有N条绳子,它们的长度分别为Li.如果从它们中切割出K条长度相同的 绳子,这K条绳子每条最长能有多长?答案保留到小数点后2位. 输入输出格式 输入格式: 第一行两个整数N和K,接下来N行,描 ...

  5. Log4j记录日志到数据库

    1.自定义输出消息 /** * 参数化消息 * @author Johnson.Lee * */ public interface ParameterizedMessage extends Seria ...

  6. C语言基础之while的使用

    一. 格式: 1: while (条件) 2:   3: { 4:   5: 循环体 6:   7: } 8:   二.运行原理 1.如果一开始条件就不成立,永远不会执行循环体 2.如果条件成立,就会 ...

  7. 几个有用的PHP.ini配置项-路径和目录

    几个有用的PHP.ini配置项-路径和目录 路径和目录1.include_path = string作用域:PHP_INI_ALL默认值:NULL此参数指定的路径是include().require( ...

  8. 一致性hash-java实现treemap版

    把不同号段的数据储存在不同的机器上,以用来分散压力.假如我们有一百万个QQ号,十台机器,,如何划分呢? 最简单粗暴的方法是用QQ号直接对10求余,结果为0-9 分别对应上面的十台机器.比如QQ号为 2 ...

  9. 个人对JAVA的SSH三大框架组合的偏见

    多数人JavaWeb的入门是学习SSH:struts+spring+hibernate:我在十年前(2006年)学习的,那时火的是struts1.x ,struts2还没诞生.   这三个框架组合,我 ...

  10. domino数据同步到sql server

          近期有个需求,要同步domino数据到selservlet数据库,查看几年前ls使用odbc写的同步功能,还能正常使用.而且加入读者域进去功能(之前没有这个需求).改进成网页配置版本号(曾 ...