cf478A Initial Bet
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.
div2A的sb题
读入5个数,如果平均数除五除不尽或者平均数是0就输出-1,否则输出平均数
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int a,b,c,d,e,f;
int main()
{
a=read();b=read();c=read();d=read();e=read();
f=a+b+c+d+e;
if(f%!=||f/==)
{
printf("-1");
return ;
}else printf("%d",f/);
}
cf478A
cf478A Initial Bet的更多相关文章
- A. Initial Bet(Codeforces Round #273)
A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 【CODEFORCES】 A. Initial Bet
A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 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 478A.Initial Bet 解题报告
题目链接:http://codeforces.com/problemset/problem/478/A 题目意思:简单来说,就是初始化的时候,五个人的值都是 b,现在给出每个人最终的状态:就是经过互相 ...
- Codeforces Round #273 (Div. 2)
A. Initial Bet 题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况 #include<iostream> #include<cstdio> #incl ...
- cf Round#273 Div.2
题目链接,点击一下 Round#273 Div.2 ================== problem A Initial Bet ================== 很简单,打了两三场的cf第一 ...
- 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 ...
- Tempdb initial size和dbcc shrinkfile
在使用sql server时您可能遇到过下面的情况,tempdb的数据文件初始大小为3mb, 随着对tempdb的使用,tempdb文件逐渐变得很大(例如30GB),导致了磁盘空间不足. 此时您需要立 ...
- INITIAL参数设置导致TRUNCATE TABLE不能降低高水位线案例
在一个数据库使用下面SQL找出了一批需要降低高水位线的表,其中有几个表没有数据,于是我打算用TRUNCATE来降低高水位线HWM SELECT a.owner, a.segment_na ...
随机推荐
- HTML5 CSS3 诱人的实例 :模仿优酷视频截图功能
一般的视频网站对于用户上传的视频,在用户上传完成后,可以对播放的视频进行截图,然后作为视频的展示图.项目中也可以引入这样的功能给用户一种不错的体验,而不是让用户额外上传一张展示图. 效果图: 看起来还 ...
- Sqrt(x) 解答
Question Implement int sqrt(int x). Compute and return the square root of x. Solution 1 -- O(log n) ...
- 应用程序打包(ipa)
如果想让用户可以安装ipa, 必须在打包程序的时候说清楚哪一个应用程序(appid)可以安装到哪一台设备上.(UDID). 原理: 要想打包, 告诉苹果, 哪一台电脑可以进行打包 步骤: 让电脑端具备 ...
- poj 3320 Jessica's Reading Problem(尺取法)
Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The fina ...
- iOS 面试常见问题最全梳理
序言 目前形势,参加到iOS队伍的人是越来越多,甚至已经到供过于求了.今年,找过工作人可能会更深刻地体会到今年的就业形势不容乐观,加之,培训机构一火车地向用人单位输送iOS开发人员,打破了生态圈的动态 ...
- iOS面试知识点
1 iOS基础 1.1 父类实现深拷贝时,子类如何实现深度拷贝.父类没有实现深拷贝时,子类如何实现深度拷贝. 深拷贝同浅拷贝的区别:浅拷贝是指针拷贝,对一个对象进行浅拷贝,相当于对指向对象的指针进行复 ...
- root密码忘记后如何修改
方法一: 1.在DOS窗口下输入net stop mysql5 或 net stop mysql 2.开一个DOS窗口,这个需要切换到mysql的bin目录.一般在bin目录里面创建一个批处理1.ba ...
- mvc初学controller参数传递感想
从视图中传递参数给controller也有很多种方式 方法一(推荐):路由 config.Routes.MapHttpRoute( name: "DefaultApi", rout ...
- Android防止内存泄漏以及MAT的使用
Android发生内存泄漏最普遍的一种情况就是长期保持对Context,特别是Activity的引用,使得Activity无法被销毁.这也就意味着Activity中所有的成员变量也没办法销毁.本文仅介 ...
- StackOverflow程序员推荐:每个程序员都应读的30本书
“如果能时光倒流,回到过去,作为一个开发人员,你可以告诉自己在职业生涯初期应该读一本,你会选择哪本书呢?我希望这个书单列表内容丰富,可以涵盖很多东西.” 很多程序员响应,他们在推荐时也写下自己的评语. ...