#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. haproxy配置直接重定向url

    在邮件列表看到有个人问haproxy能否在接到一个请求时选择一个后端服务器,然后301重定向url .主要原因是他有5个1G的出口,这样就能充分利用其带宽.测试了一下是可以的 frontend fre ...

  2. [NOIP2011]数的划分

    本题地址:http://www.luogu.org/problem/show?pid=1025 题目描述 将整数n分成k份,且每份不能为空,任意两份不能相同(不考虑顺序).例如:n=7,k=3,下面三 ...

  3. 【CSS3】Advanced5:At Rules:@import, @media, and @font-face

    1.@import bolt another stylesheet onto your existing one. @import url(**.css); must be placed at the ...

  4. codeforces 664A Complicated GCD

    水题..[a,b]区间数的最大公约数. a==b输出a 否则输出1 #include<cstdio> #include<cstring> #include<iostrea ...

  5. leetcode@ [51/52] N-Queens

    https://leetcode.com/problems/n-queens/ class Solution { public: void dfs(vector<vector<string ...

  6. POJ1276 - Cash Machine(多重背包)

    题目大意 给定一个容量为M的背包以及n种物品,每种物品有一个体积和数量,要求你用这些物品尽量的装满背包 题解 就是多重背包~~~~用二进制优化了一下,就是把每种物品的数量cnt拆成由几个数组成,1,2 ...

  7. Sitemap Editors for Dynamics CRM 2013

    I’ve started using a couple of different sitemap editors in my projects for CRM 2013. These tools he ...

  8. NDK编译路径问题

    有点偷懒,在一个使用了jni工程里面稍微修改一下,编译另外一个jni工程. 代码写完后,Android.mk等文件也写好,但是ndk-build的时候提示Android NDK:Your APP_BU ...

  9. smarty对网页性能的影响--开启opcache

    在上一篇<smarty对网页性能的影响>中,默认没有开启opcache,于是我安装了一下zend opcache扩展,重新实验了一下,结果如下: 有smarty 用apache的ab命令进 ...

  10. Git学习资料

    1.http://wuyuans.com/2012/05/github-simple-tutorial/ 2.http://www.ihref.com/read-16369.html