#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. Request Connection: Remote Server @ 192.229.145.200:80

    录制Loadrunner脚本时,提示: Request Connection: Remote Server @ 192.229.145.200:80   NOT INTERCEPTED!(REASON ...

  2. 重装mysql步骤

    , 卸载MySQL 2, 删除目录 C:\Documents and Settings\All Users\Application Data\MySQL (这个真的有,原先没注意到,删掉!) 如果没有 ...

  3. Word恢复文本转换器-修复损坏的WORD文件

    第一步:找任意一个未损坏的文件打开word,新建的或者是已有的好的word文档,在文档的工具-选项-常规中,选中“打开时确认转换”复选框,并按确定. 第二步:点击word软件左上角的 文件-打开,找到 ...

  4. HW4.10

    public class Solution { public static void main(String[] args) { int count = 0; for(int i = 100; i & ...

  5. java动态编程库,利用动态编程打印运行时调用全景(函数调用关系链)

    如果是一般java程序,不追求性能极致,想使用方便,推荐使用 Javassist 库. 如果是android程序,或者一般java程序欲追求性能极限,推荐使用 asm for java 及 asmde ...

  6. SIP SDP RTSP RTP RTCP webrtc

    rfc1889  rfc2326  rfc3261  rfc3550  rfc3856  rfc6120. SIP SDP RTSP  RTP RTCP,就像他们出现的顺序一样,他们在实际应用中的启用 ...

  7. nginx + lua 构建网站防护waf(一)

    最近在帮朋友维护一个站点.这个站点是一个Php网站.坑爹的是用IIS做代理.出了无数问题之后忍无可忍,于是要我帮他切换到nginx上面,前期被不断的扫描和CC.最后找到了waf这样一个解决方案缓解一下 ...

  8. fedora21安装xmind7

    老版本的xmind安装方法,在最后的阶段无法成功注册到系统中,desktop无法自定义完成.参考:http://www.cnblogs.com/cupcoffee/p/3560626.html 直到从 ...

  9. nginx 重装添加http_ssl_module模块

    起因: 如果出现“[emerg] 10464#0: unknown directive "ssl" in /usr/local/nginx-0.6.32/conf/nginx.co ...

  10. MapKit框架使用

    MapKit框架使用 一.地图的基本使用 1.简介 MapKit:用于地图展示,例如大头针/路线/覆盖层展示等(着重界面展示) 使用步骤: 导入主头文件 MapKit/MapKit.h MapKit有 ...