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;
}

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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • AWVS基本用法_awvs网页版使用教程

    AWVS基本用法_awvs网页版使用教程什么是AWVSAcunetixWebVulnerabilityScanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网络爬虫测试你的网站安全,检测流行安全漏洞,现已更新到10。(下面用的是AWVS9)

  • 解决docker下载镜像速度过慢_docker image是什么

    解决docker下载镜像速度过慢_docker image是什么前言上一篇讲到pull镜像,但是pull镜像的时候下拉的速度实在感人,有什么解决办法吗?我们只需将docker镜像源修改为国内的将docker镜像源修改为国内的:在/etc/docker/d

  • centos7.4安装docker_centos安装python3.6

    centos7.4安装docker_centos安装python3.6前言当我们在一台电脑上搭建了python3.6的环境,下次换台电脑,又得重新搭建一次,设置环境变量等操作。好不容易安装好,一会提示pip不是内部或外部命令,一会又提示pip:commandno

  • javaWeb前后台交互(二)[通俗易懂]

    javaWeb前后台交互(二)[通俗易懂]接上一篇javaWeb前后台交互。链接:https://blog.csdn.net/blackplus28/article/details/80603863一、MVC思想责任分离思想.M:Model,数据模型对象.(JavaBean)V:View,视图界面.(JSP,Panel,Window)C:Controller,控制器(Servlet)本次代码采用:Tomc…

  • Ubuntu16.04安装ros_u盘安装双系统

    Ubuntu16.04安装ros_u盘安装双系统一、win10下安装Ubuntu16.04双系统1、制作系统U盘下载Ubuntu16.04我们首先去Ubuntu官网下一个Ubuntu16.04的iso镜像文件。

  • SHFileOperation函数使用的介绍

    SHFileOperation函数使用的介绍今天看到一个关于SHFileOperation函数使用的介绍,发现下面一些有用的资料,都是些之前未仔细了解的方面,这里把他们记录下来,留待以后查阅参考。fFlags成员标志间的关系标志抑制的对话框相关性与优先级FOF_MULTIDESTFILES无无FOF_FILESONLY

发表回复

您的电子邮箱地址不会被公开。

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