Ace of Aces
Description
There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the deep universe that we humans have not discovered yet. This year, the TSAB decided to elect an outstanding member from its elite troops. The elected guy will 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 will be elected as the "Ace of Aces". If there are two or more candidates have the same number of nominations, no one will win.
Please write program to help TSAB determine who will be the "Ace of Aces".
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of 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, output the ID of the candidate who will be honored with "Ace of Aces". If no one win the election, output "Nobody" (without quotes) instead.
Sample Input
3
5
2 2 2 1 1
5
1 1 2 2 3
1
998
Sample Output
2
Nobody
998
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int a[];
int f[]; int main()
{
int t,n,x,flag;
int maxx;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(f,,sizeof(f));
maxx=-;flag=;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
f[a[i]]++;
}
for(int i=;i<;i++)
{
if(f[a[i]]>maxx)
{
maxx=f[a[i]];
x=a[i];
}
}
for(int i=;i<;i++)
if(f[a[i]]==maxx&&a[i]!=x)
flag++;
if(flag>)
printf("Nobody\n");
else
printf("%d\n",x);
}
return ;
}
Ace of Aces的更多相关文章
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 第十二届浙江省大学生程序设计大赛-Ace of Aces 分类: 比赛 2015-06-26 14:25 12人阅读 评论(0) 收藏
Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization called T ...
- ZOJ 3869 Ace of Aces
There is a mysterious organization called Time-Space Administrative Bureau (TSAB) in the deep univer ...
- 水题 ZOJ 3869 Ace of Aces
题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)
Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization c ...
- 【windows 访问控制】十一、C# 实操 对象 System.Security.AccessControl 命名空间
AccessControl 命名空间 结构图 解说: DirectorySecurity=目录ACLFileSecurity=文件ACLFileSystemAuditRule=目录和文件中SACL中的 ...
- ACE的构建(VC++6.0环境)
ACE的构建(VC++6.0环境)Windows下ACE的构建1. 将ACE-5.5.zip解压到所需的安装目录,此处以E:/为例,解压后形成ACE_wrappers文件夹,因此ACE将会存在于ACE ...
- Windows Server 2008及以上系统磁盘无法查看(About UAC and ACE)
在windows Server2008及以上系統,如果UAC Enabled,ACE列表中不會包含Administrators成員的SID,所以即使你是administrators的成員,也無法訪問D ...
- Microsoft ACE OLEDB 12.0 数据库连接字符串
Excel 97-2003 Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myOldExcelFile.xls;Extended ...
随机推荐
- HDU 4786 生成树 并查集+极大极小值 黑白边 确定选择白边的数量
题意: 给定一个无向图 n 个点 m条无向边 u v val val == 1 表示边(u, v) 为白边 问能否找到n个点的生成树, 使得白边数为斐波那契数 思路: 并查集求图是否连通( 是否存在生 ...
- ORACLE的执行计划
转自:http://www.cnblogs.com/lovingprince/archive/2007/12/07/2166400.html 背景知识: 为了更好的进行下面的内容我们必须 ...
- Ural 1079 - Maximum
Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements: a0 ...
- iOS8的屏幕旋转的问题
判断横竖屏.http://www.cocoachina.com/ask/questions/show/121301 //self.cameraView是相机view - (NSUInteger)sup ...
- Python 2.7 学习笔记 基本知识
python是一种解释型的.面向对象的.带有动态语义的高级程序设计语言.本文介绍下python的基本知识. 一.安装 各种操作系统有自己的安装方法,linux系统一般都自带了python的环境.这里不 ...
- zk create() 方法
create() $path = $zkh->create($req_path, $data); $path = $zkh->create($req_path, $data, 'flags ...
- 解决screen Cannot open your terminal '/dev/pts/1'问题
转载于:http://urchin.blog.51cto.com/4356076/1153322 问题描述: userA首先登录系统,使用screen开启了一个session,然后detach这个窗口 ...
- CF#231DIV2:A Good Number
Let's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a numbe ...
- HDOJ 3790 双权值Dijkstra
#include <iostream> #include <stdio.h> #include <string.h> #include <cstring> ...
- runnable与handler结合使用,其实跟在Thread中的run()中sleep的效果是一样的
这是一种可以创建多线程消息的函数使用方法:1,首先创建一个Handler对象Handler handler=new Handler();2,然后创建一个Runnable对象Runnable runna ...