Ace of Aces

Source: Internet
Author: User

Ace of Aces Time limit: 2 Seconds Memory Limit: 65536 KB

There is a mysterious organization called Time-space administrative Bureau (TSAB) in the deep universe that we Hu Mans has not discovered yet. This year, the TSAB decided to elect a outstanding member from its elite troops. The elected guy would be honored with the title of "Ace of Aces".

After voting, the TSAB received N valid tickets. On each ticket, there is a number Ai denoting the ID of a candidate. The candidate with the most tickets nominated would be elected as the "Ace of Aces". If there is, or more candidates has the same number of nominations, no one would win.

Tsab determine who'll be the "Ace of Aces".

Input

There is multiple test cases. The first line of input contains an integer indicating the number of the T test cases. For each test case:

The first line contains an integer N (1 <= N <= 1000). The next line contains N integers Ai (1 <= Ai <= 1000).

Output

For each test case, the output the ID of the candidate who would be honored with "Ace of Aces". If no one win the election, output "Nobody" (without quotes) instead.

Sample Input
352 2 2 1 151 1 2 2 31998
Sample Output
2nobody998




#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace Std;

#define N 1010

struct node
{
int A, B;
}p[n];

BOOL CMP (Node A, Node B)
{
return A.A < B.A;
}
int main ()
{
int I, t, N, num;

scanf ("%d", &t);

while (t--)
{
scanf ("%d", &n);

for (i = 0; i < N; i++)
P[I].A = 0;

for (i = 1; I <= n; i++)
{
scanf ("%d", &num);
p[num].a++;
}

if (n = = 1)
printf ("%d", num);
Else
{
for (i = 1; i < 1010; i++)
p[i].b = i;

Sort (P, p+1010, CMP);

if (p[1009].a = = p[1008].a)
printf ("Nobody");
Else
printf ("%d", p[1009].b);
}
printf ("\ n");
}
return 0;
}


I don't know how long it's been written. What do you do when your head is not clear?
Be sure to think about things when you think about them.

Ace of Aces

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.