Codeforces Round #273 (Div. 2)-A. Initial Bet
http://codeforces.com/contest/478/problem/A
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.
解题思路:能够将硬币平均分给5个人,有一个trick就是开始都为0
1 #include <stdio.h>
2
3 int main(){
4 int a, sum = , t = ;
5 while(t--){
6 scanf("%d", &a);
7 sum += a;
8 }
9 printf("%d\n", sum >= && sum % == ? sum / : -);
return ;
}
Codeforces Round #273 (Div. 2)-A. Initial Bet的更多相关文章
- 贪心 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 题意:给出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 (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 ...
- Codeforces Round #273 (Div. 2) D. Red-Green Towers 背包dp
D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces Codeforces Round #273 (Div. 2) 478B
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 的 Codeforces Round #273 (Div. 2) --C Table Decorations
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #273 (Div. 2)D. Red-Green Towers DP
D. Red-Green Towers There are r red and g green blocks for construction of the red-green tower. Re ...
随机推荐
- Redis缓存雪崩、缓存穿透、缓存击穿、缓存降级、缓存预热、缓存更新
Redis缓存能够有效地加速应用的读写速度,就DB来说,Redis成绩已经很惊人了,且不说memcachedb和Tokyo Cabinet之流,就说原版的memcached,速度似乎也只能达到这个级别 ...
- web前端_Vue框架_设置浏览器上方的标题和图标
在创建Vue项目时一般会用默认的项目标题和图标,如下图所示: 不是很美观也可能不符合项目的需求,所以有时候就需要改变项目在浏览器上方的标签名称或者图标. 找到项目根目录的index.html,如图: ...
- 用css写三角形,宽高可设置
1.不传@h,@c === @h; 2.元素width = @w, 元素height = @h*2 3.配合上.center()实现图标居中 less版本: //上下左右居中 .center(){ p ...
- andriod ndk配置
r7及以后版本不需要再配置cywin ,留影 先在path中配置ndk的环境变量,位置为ndk的根目录,也可在图5中的位置配置环境变量
- 2013 Noip提高组 Day2
3288积木大赛 正文 题目描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是hi. 在搭建开始之前 ...
- Ionic start 创建项目报错
Installing npm packages... Error with start undefined Error Initializing app: There was an error wit ...
- Android近场通信---NFC基础(四)(转)
转自http://blog.csdn.net/think_soft/article/details/8184539 从Intent中获取信息 如果因为NFC的Intent而启动一个Activity,那 ...
- c3p0连接池的简单使用和测试1
- tracert查网络问题
tracert命令的格式为:tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] ...
- python入门之三元运算,存址方式,深浅拷贝
三元运算 格式: name = 值1 if 条件 else 值2 如果条件为True,那么将值1赋值给name,条件为False,那么将值2赋值给name 存址方式 不同的数据类型在内存中的存址方式不 ...