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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 阶段小结

    阶段小结

    2021年9月29日
    38
  • phpstorm2021.4 激活码破解方法

    phpstorm2021.4 激活码破解方法,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
    92
  • sdn网络设备主要负责_sdn 解决方案

    sdn网络设备主要负责_sdn 解决方案ONOS问世后引起广泛关注,关于ONOS与ODL的纷争不绝于耳。为了应对日益增长的带宽需求,服务提供商希望网络可以更加敏捷高效,且能从创新型服务和新型业务模式中分一杯羹得到更好的发展,至此SDN的呼声越来越高。而SDN中控制器占重要部分,是兵家必争之地,陆陆续续已经出现了很多SDN控制器,如OpenDaylight、OpenContrail、Ryu、Floodlight、NOX、SPOX等等,其中

    2022年9月6日
    2
  • javascript 空格_css怎样输出空格

    javascript 空格_css怎样输出空格javascript几种写空格符的方法

    2022年10月4日
    0
  • JAVA 分布式 – 分布式介绍[通俗易懂]

    JAVA 分布式 – 分布式介绍[通俗易懂]什么是分布式系统?要理解分布式系统,主要需要明白一下2个方面:1.分布式系统一定是由多个节点组成的系统。其中,节点指的是计算机服务器,而且这些节点一般不是孤立的,而是互通的。2.这些连通的节点上部署了我们的节点,并且相互的操作会有协同。分布式系统对于用户而言,他们面对的就是一个服务器,提供用户需要的服务而已,而实际上这些服务是通过背后的众多服务器组成的一个分布式系统,因此分布式系统看…

    2022年4月26日
    49
  • 线性代数投影矩阵的定义_线性代数a和线性代数b

    线性代数投影矩阵的定义_线性代数a和线性代数bAbout投影矩阵  一个矩阵AAA既可以表示一种线性变换,又可以是一个子空间(由基张开的),还可以是一组坐标,甚是神奇。文章目录About投影矩阵一维空间的投影矩阵投影矩阵的多维推广投影的物理意义信号处理中的正交投影技术一维空间的投影矩阵  查看上图,ppp是bbb在aaa上的投影,可以发现,ppp和aaa是同向的,故可以表示为如下形式,其中xxx是标量p=axp=axp=ax  根据eee和ppp正交的条件,可以推导出x=aTbaTax=\frac{a^Tb}{a^Ta}x=aTaaT

    2022年10月4日
    0

发表回复

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

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