#include <iostream>
using namespace std;
int main()
{
int **array = new int *[100];
for ( int i = 0; i < 100; i++ )
{
array[i] = new int[2];
}
int x, y;
int t=0;
while( cin >> x >> y )
{
array[t][0] = x;
array[t][1] = y;
t++;
} for ( int i = 0; i < t; i++ )
{
int win;
int t1 = 0, t2 = 0;
if ( array[i][0] <=100 && array[i][1] <=100 )
{
win = array[i][0];
if ( win < array[i][1])
{
win = array[i][1];
}
}
else
{
int *p1 = new int[1000];
int *p2 = new int[1000];
for ( int j = 2; (j < array[i][0]/2) && (j < 101); j++ )
{
if ( array[i][0]%j == 0 && array[i][0]/j <=100 && array[i][0]/j != j )
{
p1[t1] = j;
t1++;
//cout << j << endl;
}
} for ( int j = 2; (j < array[i][1]/2) && (j < 101); j++ )
{
if ( (array[i][1]%j == 0) && (array[i][1]/j <=100) && array[i][1]/j != j )
{
p2[t2] = j;
t2++;
//cout << j << endl;
}
} if ( array[i][0] > 100 && array[i][1] > 100 && t1 == 0 && t2 == 0 )
{
win = array[i][0];
if ( win < array[i][1] )
{
win = array[i][1];
}
}
else if (array[i][0] > 100 && array[i][1] > 100 && t1 == 0 && t2 != 0)
{
win = array[i][1];
}
else if (array[i][0] > 100 && array[i][1] > 100 && t1 != 0 && t2 == 0)
{
win = array[i][0];
}
else if (array[i][0] > 100 && array[i][1] > 100 && t1 == 2 && t2 == 2 )
{
int m;
for ( m = 0; m < 2; m++ )
{
if ( p1[m] == p2[0] || p1[m] == p2[1])
{
break;
}
}
if ( m == 2 )
{
win = array[i][0];
if ( win < array[i][1] )
{
win = array[i][1];
}
}
else
{
win = array[i][0];
if ( win > array[i][1] )
{
win = array[i][1];
}
}
}
}
cout << win << endl;
} return 0;
}

  

ACM/ICPC ZOJ1003-Crashing Balloon 解题代码的更多相关文章

  1. ACM/ICPC ZOJ1006-Do the Untwist 解题代码

    #include <iostream> #include <string> #include <stdlib.h> using namespace std; int ...

  2. ZOJ1003 Crashing Balloon

    Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's ...

  3. 2013 ACM/ICPC 成都网络赛解题报告

    第三题:HDU 4730 We Love MOE Girls 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4730 水题~~~ #include < ...

  4. hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告

    这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...

  5. hdu 4763 && 2013 ACM/ICPC 长春网络赛解题报告

    一个KMP的简单题 不过好久没用过这个东东了,今天写的时候花了很多时间: 只需要花点时间判断下所有的元素都相同的的情况就行了! #include<cstdio> #include<c ...

  6. 【Acm】算法之美—Crashing Balloon

    题目概述:Crashing Balloon On every  June 1st, the Children's Day, there will be a game named "crash ...

  7. 【ZOJ1003】Crashing Balloon(DFS)

    Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's ...

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

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

  9. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

随机推荐

  1. QTP自传之初识

    我叫QTP,全名是HP Quicktest Professional,大家都叫我小Q. 小Q生于1998年,那是一个春天(哈哈咱也是跨世纪的人才).家里人丁兴旺,兄弟众多,L(Loadrunner), ...

  2. 解决easyui和bootstrap兼容问题

    在使用bootstrap和easyui的时候,发现很多有冲突的地方,包括datagrid控件和combo等,以下进行的问题修正,保证easyui正常显示 /*bootstrap兼容问题和easyui的 ...

  3. The Moving Points

    Problem Description There are N points in total. Every point moves in certain direction and certain ...

  4. 从html5标准的正式发布到国内CMS的变革

    10月底万维网联盟(W3C)宣布,经过将近8年的艰辛努力,HTML5标准规范终于最终制定完成并正式发布. W3C的正式批准让人们对HTML5更有信心.“这是一个里程碑,标志着很多人员在长达七年时间内投 ...

  5. Git log高级用法

    格式化Log输出 首先,这篇文章会展示几种git log格式化输出的例子.大多数例子只是通过标记向git log请求或多或少的信息. 如果你不喜欢默认的git log格式,你可以用git config ...

  6. 一分钟快速入门openstack

    一.它是什么,能干什么想认识一个事物,必须先弄明白它是什么,能干什么.首先说一下,openstack是一个搭建云平台的一个解决方案,说他不是个软件,但是我觉得说是一个软件,能够让大家认识更清晰些.op ...

  7. HDOJ-ACM1425 sort 简单hash应用

    其实快排也可以通过这个问题~不是考点 没想到考点是这个,简单hash应用,空间换时间 初始化一个长度为1000001的数组(由于数字的范围为[-500000,500000]) 如果存在这个数m,数组下 ...

  8. Linux中find、grep命令详细用法

    在linux下面工作,有些命令能够大大提高效率.本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们.本文结构如下: find命令 find命令的一般形式 ...

  9. canvas createRadialGradient 用法

    径向渐变,就是环形的渐变了,由圆心(或者是较小的同心圆)开始向外扩散渐变的效果,听着有些抽象,往下看图一下子就明白了.线性渐变指定了起点和终点,径向渐变则指定了开始的结束园的圆心和半径.这里使用cre ...

  10. .Net设计模式_开篇

    前言 其实以前看过两次设计模式,现在想来,几乎已经对设计模式没有任何印象,说明根本没有理解.或者说几乎不用,所以我除了单列.工厂外的设计模式几乎全部忘记了.最近需要写一个引擎,想用UML设计整体的架构 ...