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


相关推荐

  • Chango的数学Shader世界(二十三)漩涡Shader-复数分析(深渊)「建议收藏」

    Chango的数学Shader世界(二十三)漩涡Shader-复数分析(深渊)「建议收藏」目的:我的2D游戏,需要一个有特定感觉的“漩涡shader”。上一节里,我简单实现了这个:但转动有些乏味,它的转动动作是类似这样的:(网图)接下来想让它动起来更加深邃,恐怖。本文先搞了2种效果:(图3,扩散瞳孔)(图4,深渊)抽象分析:前篇的Shader效果之所以看起来乏味,是因为在旋转的时候,像素点的极长(以方块中心为原点极坐标系)并没有改变,只是越接近中心,点的旋转量越小而已。(旋转前后点都在同心圆上)如果我想要深渊有“吃人”的感觉,那么内部的

    2022年6月19日
    37
  • jar 包与 war 包区别

    jar 包与 war 包区别参考:https://www.jianshu.com/p/3b5c45e8e5bdhttps://www.cnblogs.com/banml/p/11767305.htmlhttps://blog.csdn.net/cjw12581/article/details/107463971文章目录1.jar包jar与zip异同jar包主要用途2.war包war包部署优势开发阶段不适合使用war的原因部署war包到tomcat3.jar包vs.war包SpringB

    2022年5月10日
    39
  • ARM指令中LDR与MOV的区别与应用——看这一篇就够了

    ARM指令中LDR与MOV的区别与应用——看这一篇就够了ARM指令中LDR与MOV的区别与应用、从内存中寻址的方法、LDR伪指令和MOV指令的异同

    2022年6月17日
    28
  • 3_1符合python语言变量_中国大学MOOC: 以下选项中不符合Python语言变量命名规则的是以下选项中不符合Python语言变量命名规则的是 答案:3_1…[通俗易懂]

    3_1符合python语言变量_中国大学MOOC: 以下选项中不符合Python语言变量命名规则的是以下选项中不符合Python语言变量命名规则的是 答案:3_1…[通俗易懂]劳心者治人,劳力者治於人”,孟子之,其所以驳()也。俟:农人家当睫状肌缩,悬韧带弛时,晶状体者也:前面曲率增,折光力强人生直为人观之义,是指()耳:生人之用于世与人所有之用、意义量人生直之格宜为()耳:劳、贡献宜从四方来得新时两步行要之位置。中国大学MOOC口被虫伤之者其主何护问答:焦思、惧中国大学MOOC口以下于北方经制论不正者是也:邑化率增速高中国大学MOOC口补虚药为补虚扶弱,正体气血阴阳虚…

    2022年6月10日
    42
  • aspice培训试题(软件测试教程)

    软件详细设计在ASPICE中代号是SWE3,处于V模型的左侧;软件测试则包含软件单元测试(SWE4),软件集成测试(SWE5)以及软件合格性测试(SWE6)三部分,处于V模型的右侧。下面我会比较详细地介绍一下各过程域的实施要点和迎审会面对的主要问题。软件详细设计软件详细设计要准备的第一份交付件就是:软件详细设计文档!文档的输入是软件的需求,内容应该涵盖数据结构定义,全局变量和宏定义描述,动态行为描述(任务/中断/需求方案分析等),每个函数的实现(输入/输出/返回/伪码等),详细设计评估(关键性、复杂

    2022年4月13日
    328
  • js中换行_input怎么不换行

    js中换行_input怎么不换行”\n”为换行转移符,注意\n前后的空格!!!varname=$(“#name”);varname=”姓名:”+name+”\n”;2020年1月补充:一年前的文章,现在忘了当时换行是为了干什么,好像是弹出框消息太长,会自动换行。但是希望一句一句的换行。自动换行效果:\n换行效果:<!DOCTYPEhtml><…

    2025年7月8日
    6

发表回复

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

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