Ignatius and the Princess IV(精简的算法)

题目:点击打开链接

#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<string.h>
int v[100000]={0},z[10000],p[10000],ll[10000];
using namespace std;


int main()
{
    int a,b,c,i=0,j=0,e,f,aa,bb,o,k=0,cc=0,t,q,h,hh;
    while(scanf("%d",&a)!=EOF)
    {
        int v[100000]={0};  //数组的初始化;
        for(i=0;i<a;i++)
        {
            scanf("%d",&b);
            v[b]++;    //输入相同的a的个数;
            if(v[b]==(a+1)/2)
            {
                e=b;
            }
        }
         printf("%d\n",e);
    }


    return 0;
}

猜你喜欢

转载自blog.csdn.net/soul778888/article/details/79758148