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 ...
随机推荐
- cf486C Palindrome Transformation
C. Palindrome Transformation time limit per test 1 second memory limit per test 256 megabytes input ...
- Shortest Word Distance 解答
Question Given a list of words and two words word1 and word2, return the shortest distance between t ...
- DBA 经典面试题(5)
国外公司的Oracle DBA试题 Oracle DBA Interview Questions 1. How many memory layers are in the shared pool? 2 ...
- yum笔记
rpm --> yum HTML: HyperText Mark LanguageXML: eXtended Mark Language XML, JSON: 半结构化的数据 yum仓库中的元数 ...
- Android系统进程间通信(IPC)机制Binder中的Server启动过程源代码分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6629298 在前面一篇文章浅谈Android系 ...
- iOS之Swift语言的学习
好久都没有来这个熟悉而又陌生的地方啦, 想想已经有两三个月了吧,不过我相信以后还是会经常来的啦,因为忙碌的学习已经过去啦,剩下的就是要好好的总结好好的复习了,好好的熟悉下我们之前学习的知识点,将他们有 ...
- JS回调函数的使用和作用
<html> <head> <title>回调函数(callback)</title> <script language="javasc ...
- NET中级课--设计模式1
1.分类 创建型 结构型 行为型 2.总体思路 使用接口和抽象类 3.创建型 工厂: 单例:整个系统中对象是唯一的或固定数目的对象如对象池 4.结构型
- CDMA电信短信猫支持189等电信号码可二次开发
CDMA电信短信猫支持189等电信号码可二次开发 这款短信猫采用法国wavecom Q2358C模块,支持短信猫二次开发,可提供短信猫二次开发包下载测试.提供相关资料文档. 此款CDMA电信短信猫有串 ...
- c# 运算符 ?、??、?:
用途:简化代码 说明: ? 是可空类型和运算符 int a; //a<>null int ?b; //b=null int ?c = b+1; //c=null; ?? 是空接合运算符 i ...