Description

There are N people want to choose the best person. Each person select the best person $a_i$, .John wants to know that who received the most number of votes.      
              

Input

The first line contains a single integer $T(1 \leq T \leq 50)$,indicating the number of test cases.        Each test case begins with an integer $N(1 \leq N \leq 100)$,indicating the number of person.        Next N lines contains an integer $a_i(1 \leq a_i \leq N)$.      
              

Output

For each case, output an integer means who is the best person. If there are multiple answers, print the minimum index.      
              

Sample Input

2 10 1 2 3 4 5 6 7 8 9 10 5 3 3 3 3 3
              

Sample Output

1 3
 
 
 
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
int t,n,num,maxn;
int a[];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
maxn=-;
memset(a,,sizeof(a));
for(int i=;i<=n;i++)
{
scanf("%d",&num);
a[num]++;
if(a[num]>maxn)
{
maxn=a[num];
}
}
for(int i=;i<=n;i++)
{
if(a[i]==maxn)
{
printf("%d\n",i);
break;
}
}
}
return ;
}

随机推荐

  1. JSP+Ajax站点开发小知识

    一.JSP基础 1.<select  name="love"  size="3">当中的size属性指定了列表框显示选项的条数.假设全部选项多于这个 ...

  2. uva live 6190 Beautiful Spacing (二分法+dp试 基于优化的独特性质)

    I - Beautiful Spacing Time Limit:8000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu ...

  3. oracle物化视图使用+hibernate

    使用过程 ----删除 TRUNCATE TABLE mlog$_xxx_lxz_tmp;DROP MATERIALIZED VIEW LOG ON xxx_lxz_tmp; drop materia ...

  4. Code::Blocks项目配置基础

    File 菜单 New :新建( Empty file/file . class . project . build target ) . Recent projects/files :近期打开的项目 ...

  5. 系统如何端子app弄root才干

    最近由于调试USB OTG怪东西.这导致USB端口被占用,这项.虽然我是project版本号,但不能运行adb shell,这是不可能的debug该. 所以,我现在是一个系统终端apk,规划 http ...

  6. SIGPIPE并产生一个信号处理

    阅读TCP某物,知道server并关闭sockfd当写两次,会产生SIGPIPE信号,假如不治疗,默认将挂起server 弄个小样本试验: #include <unistd.h> #inc ...

  7. hdoj 2121 Ice_cream’s world II 【没有最低树的根节点】

    称号:pid=2121" target="_blank">hdoj 2121 Ice_cream's world II 题意:题目是一道躶题,给n个点,m条边的有向 ...

  8. Cocos2d-x 3.0 Lua编程 之 响应物理引擎的Contact事件回调不运行的问题

    在较早的版本号如3.0beta使用例如以下代码的话: -- add ground local groudNode = cc.Node:create() groudNode:setPhysicsBody ...

  9. HDU 4125 Moles 段树+KMP

    意甲冠军: 特定n, 下面是一个1-n该装置. 下面的二进制字符串. 按给定的建立二叉树安排. 然后遍历树(根->左子树->根->右子树->根) 当遍历节点 如果右值为奇数入栈 ...

  10. Log4NET 数据库

    阅读目录 Log4NET简介 前提 详细步骤 回到顶部 Log4NET简介 log4net库是Apache log4j框架在Microsoft .NET平台的实现,是一个帮助程序员将日志信息输出到各种 ...