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