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. pycharm配置pep8

    可以使用外部工具,来检查代码是否符合pep8的风格: 1)下载 autopep8,这个简单,pip3 install pep8 2)在pychamr中配置: A)file-setting..-tool ...

  2. 如何跳转到其他APP(android)

    有很多小伙伴会遇上这样的需求,从自己的app页面跳转到其他APP界面,一般情况下都是在自己的主包中跳转到公司其他APP,或者是合作方的APP,如果手机中没有这款APP会下载这款APP . 今天,博主就 ...

  3. 51nod 1090 3个数和为0【二分】

    1090 3个数和为0 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 给出一个长度为N的无序数组,数组中的元素为整数,有正有负包括0,并互不相等.从 ...

  4. Git&GitHun 命令合集

    Git&GitHun 命令合集 基本操作 git --version 查看git版本信息 git add 本地库初始化 设置签名 git config user.name xxx git co ...

  5. maven的知识图谱

    maven 1.maven的好处 java项目管理工具 依赖管理 对jar包统一管理 项目名称 公司/组织 版本信息 本地仓库 由于索引的存在,找jar包很快 项目构建 依赖管理 传统项目 很大 包含 ...

  6. Codeforces 1010D Mars rover

    题目大意:对于一个不完全二分图,根节点为1,叶节点值为0或1,非叶节点包含一个操作(and,or,xor,not),求改变各个叶节点的值时(即0改为1,1改为0),根节点的值是多少 解法:遍历图求各节 ...

  7. POJ 1990 MooFest(zkw线段树)

    [题目链接] http://poj.org/problem?id=1990 [题目大意] 给出每头奶牛的位置和至少要多少分贝的音量才能听到谈话 现在求奶牛两两交流成功需要的分贝*距离的总和. [题解] ...

  8. spring属性注入

    1,set方法注入 (1)对于值类型的属性: 在对象中一定要有set方法 package com.songyan.demo1; import com.songyan.injection.Car; /* ...

  9. Spark-submit脚本解读

    #!/usr/bin/env bash # # Licensed to the Apache Software Foundation (ASF) under one or more # contrib ...

  10. XCTest(一)

    target:  + 来添加target,可以选择工程中不同的target目标来添加 class: +来添加class, 可以按照不同的测试功能来分类,比如NormalFunctionTest, UI ...