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;
}
目录
相关文章
POJ 2390 Bank Interest
POJ 2390 Bank Interest
104 0
|
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.
1298 0
|
Java
2017 Multi-University Training Contest - Team 1 1001&&HDU 6033 Add More Zero【签到题,数学,水】
Add More Zero Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 398    Accepted Submission(s)...
1136 0
POJ 2390 Bank Interest
Problem Description Farmer John made a profit last year! He would like to invest it well but wonders how much money he will make.
818 0