杭电HDOJ 1029 Ignatius and the Princess IV
来源:互联网 发布:java构造方法何时调用 编辑:程序博客网 时间:2024/04/30 23:59
#include<stdio.h>
#include<string.h>
#define max 1000000
int a[max];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(a,sizeof(a),0);
int tatol=(n+1)/2;
int tem,num;
for(int i=0;i<n;i++)
{
scanf("%d",&num);
a[num]++;
if(a[num]>=tatol)
{
tem=num;
}
}
printf("%d\n",tem);
}
return 0;
#include<string.h>
#define max 1000000
int a[max];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(a,sizeof(a),0);
int tatol=(n+1)/2;
int tem,num;
for(int i=0;i<n;i++)
{
scanf("%d",&num);
a[num]++;
if(a[num]>=tatol)
{
tem=num;
}
}
printf("%d\n",tem);
}
return 0;
}
//输入负数同样能得出正确结果!
//如果采用常规一一列举的方法会超时!
0 0
- 杭电HDOJ 1029 Ignatius and the Princess IV
- 【HDOJ】1029 -> Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- HDOJ Ignatius and the Princess IV 1029
- HDOJ 1029 Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- hdoj-1029-Ignatius and the Princess IV
- hdoj 1029 Ignatius and the Princess IV
- HDOJ 1029 Ignatius and the Princess IV
- 杭电OJ(HDOJ)1029题:Ignatius and the Princess IV(数论)
- 杭电OJ 1029:Ignatius and the Princess IV
- 杭电 1029 Ignatius and the Princess IV
- 杭电 HDU 1029 Ignatius and the Princess IV
- c语言杭电1029Ignatius and the Princess IV
- 杭电1029 Ignatius and the Princess IV
- 杭电1029 之 Ignatius and the Princess IV
- 基于springmvc的json传值
- Android开发难点
- lua的 repeat ..... until
- HDU 5980 icpc 大连
- html+css+script自学笔记零
- 杭电HDOJ 1029 Ignatius and the Princess IV
- 阿里携“骑呗”入局共享单车,好戏即将开始
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
- JAVA基础(2) -- 两个线程轮流打印1-100
- MBlock-scartch开发环境搭建
- nginx代理模块
- 汇编从0开始(1)
- 十进制与二进制相互转换(包括带小数点.各类进制转换公式)
- 面向对象的四大特性