#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=1061109567;
int a[7];
int main()
{
int sum=0,x;
for(int i=1;i<=5;++i)
{
scanf("%d",&x);
sum+=x;
}
printf("%d\n",sum==0||sum%5?-1:sum/5);
return 0;
}
/*
【trick&&吐槽】
不好好读题,自然要吃一发WA
【题意】
5个人手里,初始都有b枚硬币,b为非负整数。
经过若干次打赌后,(每次打赌结果是一个人把自己有的一枚硬币给了另外一个人),告诉你每个人最后的硬币数。
依次告诉你这5个人最后的硬币数a[],(0<=a[]<=100)。
让你判定是否可能存在一个合法的初始条件。
如果合法,输出b。如果不合法,输出-1。
【类型】
水题 语文题
【分析】
首先,b肯定只能是sum/5,所以我们要求出sum,查看sum是否是5的倍数。
如果不是显然-1.否则答案就是sum/5.
错!
虽然c[]都非负,但是c[]是可能为0的,所以我们可能会算得b==0。
于是这里也要判定为-1.
*/
【Codeforces Round 273 (Div 2)A】【水题 语文题】 Initial Bet 5人初始硬币都为b,告诉你最后的硬币数让你输出合法正整数b
最新推荐文章于 2019-05-03 14:43:00 发布
这是一个名为'Generosity'的游戏,五名玩家初始投入非零硬币数b。游戏结束后,给你每位玩家的硬币数,你需要找出可能的初始投入硬币数b,或表明无法通过任何正整数b获得这种结果。
摘要由CSDN通过智能技术生成