A. Initial Bet(Codeforces Round #273)
1 second
256 megabytes
standard input
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.
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).
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).
2 5 4 0 4
3
4 5 9 2 1
-1
In the first sample the following sequence of operations is possible:
- One coin is passed from the fourth player to the second player;
- One coin is passed from the fourth player to the fifth player;
- One coin is passed from the first player to the third player;
- One coin is passed from the fourth player to the second player.
#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)的更多相关文章
- 贪心 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 ...
- 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 ...
- Codeforces Round #273 (Div. 2)
A. Initial Bet 题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况 #include<iostream> #include<cstdio> #incl ...
- 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 ...
- CODEFORCES ROUND #273 DIV2
题目大意: A简单的说就是,有五个人,他们刚开始有B元,经过一系列过程后,给你他们现在分别有的钱,让你求出B(> <难得的傻逼题啊...但是要注意B是正整数!特判0) B有n个人,要分成m ...
- 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 ...
- 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 ...
- C. Table Decorations(Codeforces Round 273)
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- B. Random Teams(Codeforces Round 273)
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- [Cocos2d-x]Mac下运行HelloCpp For Android
2013年12月22日 一.简介: Mac下运行Cocos2d-x的samples和新建的HelloCocos2dx项目 二.内容: 环境: OS:mac OS X 10.9.1 IDE:Androi ...
- 从零开始学C++之从C到C++(二):引用、内联函数inline、四种类型转换运算符
一.引用 (1).引用是给一个变量起别名 定义引用的一般格式:类型 &引用名 = 变量名: 例如:int a=1; int &b=a;// b是a的别名,因此a和b是同一个单元 注 ...
- 在 Java 项目中解压7Zip特殊压缩算法文件
1 问题描写叙述 Java Web 后端下载了一个经特殊算法压缩的 zip 文件,由于不能採用 java 本身自带的解压方式,必须採用 7Zip 来解压.所以,提到了本文中在 java web 后端调 ...
- 解决SQL查询总是超时已过期
解决SQL查询总是超时已过期 .在WIN8里提示:OLE DB 或 ODBC 错误 : 查询超时已过期; HYT00 1.由于数据库设计问题造成SQL数据库新增数据时超时 症状: Microso ...
- 你不知道的JavaScript上卷笔记
你不知道的JavaScript上卷笔记 前言 You don't know JavaScript是github上一个系列文章 初看到这一标题的时候,感觉怎么老外也搞标题党,用这种冲突性比较强的题目 ...
- 添加PDF文件对照度的粗浅原理,及方法
上边这张照片不是异形,而是著名的鹦鹉螺.下边这张照片,是送给研究生同学的毕业纪念,向龙同学帮我激光雕刻的. 近期的照片在[http://www.douban.com/photos/album/13 ...
- ASIHttpRequest 摘要
向server端上传数据 ASIFormDataRequest ,模拟 Form表单提交,其提交格式与 Header会自己主动识别. 没有文件:application/x-www-form-urlen ...
- varchar 分享影响记忆 试
准备数据 sysbench --test=oltp --oltp-nontrx-mode=update_key --mysql-table-engine=innodb --oltp-table-siz ...
- Qt--将Qt 动态链接生成的exe及依赖dll打包方法
Qt静态编译链接生成的exe文件,不需依赖dll,可以独立运行,发布很方便. 但绝大多数用的都是Qt开源版本,如果用静态链接,会有些限制. 方法之一,就是用动态编译,然后把exe和需要的dll整合成一 ...
- ecshop 浏览历史样式的修改
ecshop的浏览历史的样式,例如我修改的是只让浏览历史显示浏览历史的商品名称 而不显示浏览历史的商品的价格和图片 首先找到要修改 的文件includes\lib_insert.php 找到函数fun ...