#include <stdio.h>#include<string.h>#include<math.h>intMain () {_int64 n,a; while(SCANF ("%i64d", &n)! =EOF) {_int64 B=0, C; while(n--) {scanf ("%i64d",&a); if(b==0) {C=A; b++; } Else { if(c==a) b++; Elseb--; }} printf ("%i64d\n", c); } return 0;}
Problem Description "OK, you aren't too bad, em ... But can never pass the next test. "Feng5166 says.
"I'll tell you a odd number N, and then N integers. There'll be a special integer among them and you've to tell me which an integer is the Special one after I tell you all the integers. "feng5166 says.
"What's the characteristic of the special integer?" Ignatius asks.
"The integer would appear at least (n+1)/2 times. If you can ' t find the right integer, I'll kill the princess, and you'll be my dinner, too. Hahahaha ... "feng5166 says.
Can you find the special integer for Ignatius?
Inputthe input contains several test cases. Each test case contains the lines. The first line consists of an odd integer N (1<=n<=999999) which indicate the number of the integers feng5166 would te ll our hero. The second line contains the N integers. The input is terminated by the end of file.
Outputfor each of the test case and you had to output only one line which contains the special number you had found.
Sample Input51 3 2 3 3111 1 1 1 1 5 5 5 5 5 571 1 1 1 1 1 1
Sample Output351
Dynamic planning: Ignatius and the Princess IV