题目链接:

  http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1054

题目大意

  多组数据,n=0结束。给定n(n<=1 000 000)和n个ip(*.*.*.*)求出现次数超过一半的ip是多少(数据保证有)。

题目思路:

  【模拟】

  暴力模拟能A。

  暴力排序能A。

排序:

 //
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 1000004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
struct xxx
{
int s1,s2,s3,s4;
}a[N];
bool cmp(xxx aa,xxx bb)
{
if(aa.s1!=bb.s1)return aa.s1<bb.s1;
if(aa.s2!=bb.s2)return aa.s2<bb.s2;
if(aa.s3!=bb.s3)return aa.s3<bb.s3;
return aa.s4<bb.s4;
}
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%d",&n) && n)
{
printf("Case %d:\n",++cas);
for(i=;i<=n;i++)
scanf("%d.%d.%d.%d",&a[i].s1,&a[i].s2,&a[i].s3,&a[i].s4);
sort(a+,a++n,cmp);
printf("%d.%d.%d.%d\n",a[(n+)/].s1,a[(n+)/].s2,a[(n+)/].s3,a[(n+)/].s4);
}
return ;
}
/*
// //
*/

千万不要点

模拟:

 //
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 256
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int u[][N];
int a,b,c,d,aa,bb,cc,dd;
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%d",&n) && n)
{
printf("Case %d:\n",++cas);
memset(u,,sizeof(u));
aa=bb=cc=dd=;
for(i=;i<=n;i++)
{
scanf("%d.%d.%d.%d",&a,&b,&c,&d);
u[][a]++;u[][b]++;u[][c]++;u[][d]++;
if(u[][a]>n/)aa=a;
if(u[][b]>n/)bb=b;
if(u[][c]>n/)cc=c;
if(u[][d]>n/)dd=d;
}
printf("%d.%d.%d.%d\n",aa,bb,cc,dd);
}
return ;
}
/*
// //
*/

千万不要点

【模拟】XMU 1054 Hacker的更多相关文章

  1. 【模拟】XMU 1055 数七

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1055 题目大意: 报数游戏,不能报7的倍数和2进制下含有111的数. 给定n,m(1& ...

  2. 【模拟】XMU 1062 山东煎饼

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1062 题目大意: 已知金钱,和各面额钞票张数,问最少可以换成几张. 题目思路: [模拟 ...

  3. 【数学】【模拟】XMU 1044 伪伪随机数产生器

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1044 题目大意: 求首项为0,公比为x的等差数列组成的数字条的第y位数字是几.(x,y ...

  4. 【模拟】XMU 1599 斐波那契汤

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1599 题目大意: 给k,m,q以及f[1]...f[k],当n<m时,f[n]= ...

  5. XMU 1606 nc与滴水问题 【模拟】

    1606: nc与滴水问题 Time Limit: 1000 MS  Memory Limit: 64 MBSubmit: 85  Solved: 27[Submit][Status][Web Boa ...

  6. hacker模拟环境

    https://geekprank.com/hacker/

  7. POJ - 1054 The Troublesome Frog 模拟 枚举优化。

    题意:有个R*C的格网.上面有若干个点,这些点可以连成一些直线,满足:这些点在直线上均匀排布(也就是间隔相等),直线的两段穿过网格(也就是第一个,最后一个在网格的边界附近) 求某条直线上最多的点数 题 ...

  8. The Hacker's Guide To Python 单元测试

    The Hacker's Guide To Python 单元测试 基本方式 python中提供了非常简单的单元测试方式,利用nose包中的nosetests命令可以实现简单的批量测试. 安装nose ...

  9. 【转】lonekight@xmu·ACM/ICPC 回忆录

    转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...

随机推荐

  1. 用htaccess进行访问控制(转)

    1. 文件访问控制 利用 httpd.conf 中的 Order.Files 及 FilesMatch 命令实现的访问控制可以满足大部分要求,但是当用户被拒绝时,他们看到的是硕大的“403 Forbi ...

  2. C#使用DataSet类、DataTable类、DataRow类、OleDbConnection类、OleDbDataAdapter类编写简单数据库应用

    //注意:请使用VS2010打开以下的源代码. //源代码地址:http://pan.baidu.com/s/1j9WVR using System; using System.Collections ...

  3. yii 验证码那点事儿

    今天要使用yii验证码, 不过, 这个验证码是整站通用的, 也就是说, 有个表单的提交是使用ajax方式来提交, 整站, 不管在哪个地方, 都能点出来此窗口, 来提交信息 关于yii验证码, fram ...

  4. 9.16noip模拟试题

    题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走,厉害吧(好吧,我自重).早苗的 ...

  5. codevs 1036 商务旅行 (倍增LCA)

    /* 在我还不知道LCA之前 暴力跑的SPFA 70分 三个点TLE */ #include<iostream> #include<cstdio> #include<cs ...

  6. 没有懂的leetcode

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...

  7. 黑马程序员-for和foreach

    class Program { static void Main(string[] args) { Console.WriteLine("***第一种情况****************** ...

  8. Android 开发笔记——对应用进行单元测试

    在实际开发中,开发android软件的过程需要不断地进行测试.而使用Junit测试框架,是正规Android开发的必用技术, 在Junit中可以得到组件,可以模拟发送事件和检测程序处理的正确性. 第一 ...

  9. 配置中的address不能重复

    <jaxws:endpoint  implementor="com.service.imp.UserServiceImpl" address="/user" ...

  10. [转]memmove函数

    [FROM MSDN && 百科] 原型:  void *memmove( void* dest, const void* src, size_tcount ); #include&l ...