游客 Signup | Login
中文 | En

3455 - 点名2

有2个同学比赛谁被点名的次数最多。必定有人比另一个人高

Input

有多组测试数据

对于没组测试数据,输入N,然后输入N个学号ai,输出出现次数最多的学号

N<= 20 0<= ai <= 5000000

Output

输出出现次数最多的学号,每个一行

Examples

Input

5
1 1 2 2 1
6
500 500 500 200 200 500

Output

1
500

Solution C

#include <stdio.h>

int main()
{
	int n, a, b, x, sum;
	while(scanf("%d",&n) != EOF)
	{
		sum = 0;
		scanf("%d",&a);
		sum ++;
		n--;
		while(n--)
		{
			scanf("%d",&x);
			if(x != a)
			{
				b = x;
				sum --;
			}
			else
				sum ++;
		}
		if(sum > 0)
			printf("%d\n",a);
		else
			printf("%d\n",b);
	}
}
Time Limit 1 second
Memory Limit 2 MB
Discuss Stats
上一题 下一题