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 ...
随机推荐
- Array vs Linked List
Access: Random / Sequential 1. Array element can be randomly accessed using index 2. Random access f ...
- Micro Python - Python for microcontrollers
Micro Python - Python for microcontrollers MicroPython
- php随机函数
<?php function generate_password( $length = 6 ) { // 密码字符集,可任意添加你需要的字符 // $chars = 'abcdefghijklm ...
- 归纳下js面向对象的几种常见写法
//定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area() 1.工厂方式 var Circle = function() { var obj = new Object(); ob ...
- 修改UITextField placeholder Color
[YourtextField setValue:[UIColor colorWithRed:97.0/255.0 green:1.0/255.0 blue:17.0/255.0 alpha:1.0] ...
- Java动态 遍历List 时删除List特征元素 异常问题 及解决方案总结
首先.这是一个极其简单的问题,大牛可忽略.新手可能会遇到,Java中遍历某个List 时删除该List元素 会抛出异常. 这一个简单的问题再高手严重不值一提,但新手可能会比較困惑,用哪种方式能够安全有 ...
- pat 1049 Counting Ones
要统计1到N之间‘1’的个数,如数11包含2个1.所以当N=12时,答案为5. 思想: 找规律,假设ans[N]表示1到N的‘1’的个数,则有a[100]=(a[10]-1)*9+10+a[10]-1 ...
- 阿里云部署Docker(5)----管理和公布您的镜像
出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...
- maven ClassNotFoundException: org.springframework.web.context.ContextLoader
信息: Starting Servlet Engine: Apache Tomcat/6.0.32 2012-3-31 9:39:40 org.apache.catalina.core.Standar ...
- [J2EE框架][Debug]
注意xml头部问题 比如在xx-servlet中注意: <mvc:annotation-driven/> <context:component-scan base-package=& ...