Hdu oj 1029 Ignatius and the Princess IV

题目:点击打开链接

代码一:

#include<stdio.h>#include<string.h>int b1[1000000];int main(){int n;while(~scanf("%d",&n)){int i;int a,t;memset(b1,0,sizeof(b1));for(i=0;i<n;i++){scanf("%d",&a);b1[a]++;if(b1[a]>=(n+1)/2)t=a;}printf("%d\n",t);}return 0;}

代码二:

#include<stdio.h>#include<string.h>int b1[1000000];int main(){int n;while(~scanf("%d",&n)){int i;int a;memset(b1,0,sizeof(b1));for(i=0;i<n;i++){scanf("%d",&a);b1[a]++;}for(i=0;i<1000000;i++)//晕,刚开始开到n, wrong answer{if(b1[i]>=(n+1)/2){break;}}printf("%d\n",i);}return 0;}

版权声明:本文为博主原创文章,,未经博主允许不得转载。

突然之间失去了语言。那才是真正的寂寞,

Hdu oj 1029 Ignatius and the Princess IV

相关文章:

你感兴趣的文章:

标签云: