hdu 5364 Distribution money

简介:

hdu 5364 的传送门
Problem Description

AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man’s money is more than the sum of all others’.He shoule be punished.Each one who get a part of money would write down his ID on that part.

Input

There are multiply cases.
For each case,there is a single integer n(1<=n<=1000) in first line.
In second line,there are n integer a1,a2…an(0<=ai<10000)ai is the the ith man’s ID.

Output

Output ID of the man who should be punished.
If nobody should be punished,output -1.

Sample Input

3
1 1 2
4
2 1 4 3

Sample Output

1
-1

题目大意:问题描述
小花是一个热爱健身的姑娘,这天她下载了一个跑步软件,这个软件可以记录下小花跑步的轨迹。小花决定去公园跑步。公园里有许许多多的座椅,小花希望在一些座椅休息一下,并且她在两条座椅之间只跑直线。小花是一个完美主义者,她希望自己最后的轨迹是一个正三边形或者正四边形或者正五边形或者正六边形。小花会从某条座椅开始打开跑步软件,并在回到这个座椅后关闭。
请问小花有多少种跑法。注:若两种跑法经过的座椅集合相同则认为是一种跑法。且经过一条座椅时没有必要一定停下来

提示:好好审题就行了:,直接上代码

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
const int maxn=1e4+5;
int a;
int b[maxn];
int main()
{
    int m;
    while(scanf("%d",&m)!=EOF)
    {
        memset(b,0,sizeof(b));
        for(int i=0; i<m; i++)
        {
            scanf("%d",&a);
            b[a]++;
        }
        int maxx=-99;
        int flag=0;
        for(int i=0; i<maxn; i++)
        {
            if(maxx<b[i])
            {
                maxx=b[i];
                flag=i;
            }
        }
        if(maxx<=m/2)
            printf("-1\n");
        else
            printf("%d\n",flag);
    }
    return 0;
}
目录
相关文章
|
12月前
|
应用服务中间件 C++ AHAS
hdu1327 Definite Values
hdu1327 Definite Values
46 0
|
6月前
|
Java
hdu-1016-Prime Ring Problem
hdu-1016-Prime Ring Problem
28 0
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
112 0
HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)
HDOJ(HDU) 2309 ICPC Score Totalizer Software(求平均值)
99 0
|
算法 iOS开发
|
人工智能 机器学习/深度学习
|
Java
2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1354    Accepted Submission(s): 496 Problem Description Mr.
1297 0