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. ajax和json数据

    一.Ajax概述 1.什么是同步,什么是异步 同步现象:客户端发送请求到服务器端,当服务器返回响应之前,客户端都处于等待     卡死状态 异步现象:客户端发送请求到服务器端,无论服务器是否返回响应, ...

  2. PHP将两个二维数组合并为一个二维数组的方法

    $a = array(0 => Array(id => 66,class_name => math),1 => Array(id => 67,class_name =&g ...

  3. 异步 JavaScript 之理解 macrotask 和 microtask(转)

    这个知识点... https://blog.keifergu.me/2017/03/23/difference-between-javascript-macrotask-and-microtask/? ...

  4. Informix 启动 Fatal error in shared memory initialization解决方法

    https://blog.csdn.net/cy309173854/article/details/54929735

  5. Android studio配置使debug签名和release签名一致

    在module的build.gradle中添加 android { //重要部分 signingConfigs { release { keyAlias 'jxt' keyPassword '1234 ...

  6. React Native WebView关闭缓存

    React Native WebView关闭缓存 网上搜索没有找到关闭React Native下webview控件的缓存的方法,经测试找到解决方案,记录如下 核心思路:通过请求时设置请求头,使页面缓存 ...

  7. HDU 1847 【巴什博弈】

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  8. 在CentOS 7上安装Node.js

    一.安装1.进入官网下载最新版本https://nodejs.org/en/ 选择下载后上传或直接使用wget下载 wget https://nodejs.org/dist/v8.11.2/node- ...

  9. luogu P1069 细胞分裂

    题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家.现在,他正在为一个细胞实 验做准备工作:培养细胞样本. Hanks 博士手里现在有 N 种细胞,编号从 1~N,一个 ...

  10. 本地navicatl连接linux

    首选你Linux服务器上要装配好了MySQL数据库.输入: # mysql -u root -proot mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@ ...