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 ...
随机推荐
- rzsz不能大于4G,securefx传5.2G没有问题,
rzsz不能大于4G,securefx传5.2G没有问题, 查看系统限制: $ulimit -acore file size (blocks, -c) 0data seg size ...
- 使用HashMap须要注意的事儿:不要暴露Map.entry给外部不可信代码Map.entrySet()
Map/HashMap是java中一种非经常常使用的数据结构,一般我们在应用中做的事情就是调用put向容器写入数据或者是get从容器读取数据. Map.entrySet()这种方法返回了键值对的集合, ...
- syslog-ng 3.4.3 发布,强烈建议升级 - 开源中国社区
syslog-ng 3.4.3 发布,强烈建议升级 - 开源中国社区 syslog-ng 3.4.3 发布,强烈建议升级 oschina 发布于: 2013年08月16日 (2评) 分享到 ...
- 第 3 章 编写 PAM 应用程序和服务
Solaris 开发者安全性指南 Previous: 第 2 章 开发特权应用程序 Next: 第 4 章 编写使用 GSS-API 的应用程序 第 3 章 编写 PAM 应用程序和服务 可插拔验证模 ...
- UVa 10188 - Automated Judge Script
题目:给你一些题目的输出结果,推断是AC,PE还是WA. 分析:模拟. 依照题意模拟就可以,注意PE条件为全部数字字符出现顺序同样就可以. 说明:想起非常多年前写的OJ的后台判题程序了╮(╯▽╰)╭. ...
- ARM架构和编程-4
ARM中断异常处理: ARM系统中止品种:按中断处理降序排列优先级:重置.数据访问中止.高速中断请求.外部中断请求.预取中止.令.软件中断. ARM体系中的异常中断向量表: 0x0 复位 0x4 没有 ...
- 漫谈并发编程(二):java线程的创建与基本控制
java线程的创建 定义任务 在java中使用任务这个名词来表示一个线程控制流的代码段,用Runnable接口来标记一个任务,该接口的run方法为线程运行的代码段. public ...
- nginx学习12 ngx_cycle_t 和 ngx_init_cycle
在nginx在启动过程,ngx_init_cycle这个函数最初始工作.变量的初始化存储在ngx_cycle_t这个结构体中,为了深入了解这个函数都做了那些初始化工作,就化时间研究了一下.并写下来以便 ...
- 《WordPress插件开发手冊》文件夹
翻译前言:国内没有关于WordPress插件开发比較具体而且系统的资料 前言 第一章:准备一个本地开发环境 介绍 在你的电脑上安装一个站点server 下载并配置一个本地的WordPress 创建一个 ...
- linux--关于shell的介绍
下面是最近学习shell的一些知识点总结***博客园-邦邦酱好*** 1.什么是shell(1)Shell将我们输入的指令与Kernel沟通,好让Kernel可以控刢硬件来正确无误地工作.(2)我们总 ...