A. Initial Bet(Codeforces Round #273)

A. Initial Bet(Codeforces Round #273)

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

A. Initial Bet
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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).

Output

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).

Sample test(s)
input
2 5 4 0 4

output
3

input
4 5 9 2 1

output
-1

Note

In the first sample the following sequence of operations is possible:

  1. One coin is passed from the fourth player to the second player;
  2. One coin is passed from the fourth player to the fifth player;
  3. One coin is passed from the first player to the third player;
  1. One coin is passed from the fourth player to the second player.      

判一下是否为5的倍数,注意特判全为0

代码:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a[10];
    int ans=0;
    for(int i=0;i<5;i++)
    {
    scanf("%d",&a[i]);
    ans+=a[i];
    }
    if(ans==0)
    {
        printf("-1\n");
        return 0;
    }
    if(ans%5==0)
    printf("%d\n",ans/5);
    else
    printf("-1\n");
    return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117712.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • mysql 替换某个字段中的某个字符

    mysql 替换某个字段中的某个字符

    2021年10月21日
  • vmware linux安装教程_vmware10虚拟机安装教程

    vmware linux安装教程_vmware10虚拟机安装教程一、安装VMware下载地址(16pro):https://www.aliyundrive.com/s/FSktJJXsfa8安装:选一下安装地址,一直下一步即可。(可能会要求重启电脑,重启即可)二、安装Linux下载地址:CentOS-7.5提取码:486k接下来看图操作2.1新建虚拟机现在我们就相当于买电脑,先把电脑配置整好。什么cpu啊内存条啊硬盘啊什么乱七八糟的,先不着急装系统。这里看你装什么版本的Linux了,我装的是GenOS7.564位所以选的是Ge

    2022年10月8日
  • pycharm 2021永久激活码【最新永久激活】

    (pycharm 2021永久激活码)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html2QQ4OQYW6M-eyJsa…

    2022年3月22日
  • amd电脑安装Android失败,AMD显卡驱动安装失败

    amd电脑安装Android失败,AMD显卡驱动安装失败是WIN7的操作系统吧,必须要取得管理员权限。方法如下:1.右键单击“计算机”,进入“管理”找到“用户和组”2.找到administrators,右键调出属性,把“该账户已禁用”前面的勾去掉。回桌面3.新建“记事本”,copy如下内容:WindowsRegistryEditorVersion5.00[HKEY_CLASSES_ROOT\*\shell\runas]@=”管理员取得所有权”…

    2022年5月6日
  • python 元类编程_python进阶路线图

    python 元类编程_python进阶路线图前言通常我们创建类都是使用class类名,但是小伙伴们有没有想过,类是由谁来创建的呢,python中常说的万物皆对象,对象是由类创建的,那类本身也可以看做是对象,类可以由元类type创建type

    2022年7月28日
  • 微信个人号机器人接口「建议收藏」

    微信个人号机器人接口「建议收藏」前段时间公司需求开发一套自定义的微信机器人,需求是可以自批量添加好友,自动聊天,自动回复,发朋友圈,转发语音,以及定时群发等,还可以提取聊天内容,进行数据汇总,what????微信还可以这样做!!调研开发了3个月,3个月啊!!!(主要被各种技术走偏路),终于成功了,都是走过的心酸泪,分享给大家,大家学习完,记得给我点个赞!!!大家一般需求点无非是以下几个需求:1.开发个人微信营销系统2.开发自定义的微信机器人,3.开发微信智能聊天客服系统4.定制行业内的群数据分析功能需求很

    2022年5月20日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号