1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int **array = new int *[100];
  6. for ( int i = 0; i < 100; i++ )
  7. {
  8. array[i] = new int[2];
  9. }
  10. int x, y;
  11. int t=0;
  12. while( cin >> x >> y )
  13. {
  14. array[t][0] = x;
  15. array[t][1] = y;
  16. t++;
  17. }
  18.  
  19. for ( int i = 0; i < t; i++ )
  20. {
  21. int win;
  22. int t1 = 0, t2 = 0;
  23. if ( array[i][0] <=100 && array[i][1] <=100 )
  24. {
  25. win = array[i][0];
  26. if ( win < array[i][1])
  27. {
  28. win = array[i][1];
  29. }
  30. }
  31. else
  32. {
  33. int *p1 = new int[1000];
  34. int *p2 = new int[1000];
  35. for ( int j = 2; (j < array[i][0]/2) && (j < 101); j++ )
  36. {
  37. if ( array[i][0]%j == 0 && array[i][0]/j <=100 && array[i][0]/j != j )
  38. {
  39. p1[t1] = j;
  40. t1++;
  41. //cout << j << endl;
  42. }
  43. }
  44.  
  45. for ( int j = 2; (j < array[i][1]/2) && (j < 101); j++ )
  46. {
  47. if ( (array[i][1]%j == 0) && (array[i][1]/j <=100) && array[i][1]/j != j )
  48. {
  49. p2[t2] = j;
  50. t2++;
  51. //cout << j << endl;
  52. }
  53. }
  54.  
  55. if ( array[i][0] > 100 && array[i][1] > 100 && t1 == 0 && t2 == 0 )
  56. {
  57. win = array[i][0];
  58. if ( win < array[i][1] )
  59. {
  60. win = array[i][1];
  61. }
  62. }
  63. else if (array[i][0] > 100 && array[i][1] > 100 && t1 == 0 && t2 != 0)
  64. {
  65. win = array[i][1];
  66. }
  67. else if (array[i][0] > 100 && array[i][1] > 100 && t1 != 0 && t2 == 0)
  68. {
  69. win = array[i][0];
  70. }
  71. else if (array[i][0] > 100 && array[i][1] > 100 && t1 == 2 && t2 == 2 )
  72. {
  73. int m;
  74. for ( m = 0; m < 2; m++ )
  75. {
  76. if ( p1[m] == p2[0] || p1[m] == p2[1])
  77. {
  78. break;
  79. }
  80. }
  81. if ( m == 2 )
  82. {
  83. win = array[i][0];
  84. if ( win < array[i][1] )
  85. {
  86. win = array[i][1];
  87. }
  88. }
  89. else
  90. {
  91. win = array[i][0];
  92. if ( win > array[i][1] )
  93. {
  94. win = array[i][1];
  95. }
  96. }
  97. }
  98. }
  99. cout << win << endl;
  100. }
  101.  
  102. return 0;
  103. }

  

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. EventHandlerList z

    写一个类时,有时候会在同一个类上添加很多事件,事件很多的话,是不容易管理的,.NET提供的EventHandlerList可以辅助多个事件的管 理,但不方便的地方是,它不是类型安全的,缺少类型安全,多 ...

  2. oracle logminer全解析

    今天写篇原创的,把在工作中遇到的logminer问题总结下 (1)简介: logminer 工具即可以用来分析在线,也可以用来分析离线日志文件,即可以分析本身自己数据库的重作日志文件,也可以用来分析其 ...

  3. 支持度(support)和置信度(confidence)

      支持度(Support)的公式是:Support(A->B)=P(A U B).支持度揭示了A与B同时出现的概率.如果A与B同时出现的概率小,说明A与B的关系不大:如果A与B同时出现的非常频 ...

  4. Clean Code – Chapter 6 Objects and Data Structures

    Data Abstraction Hiding implementation Data/Object Anti-Symmetry Objects hide their data behind abst ...

  5. 使用Windows Azure创建Linux系统虚拟机-上

    创建虚拟机来运行Linux 当您在Azure管理门户中使用映像图库时,创建运行Linux的虚拟机很容易.本指南告诉您如何做到这一点,假设你没有使用过Azure. 注意: 即使你不需要使用过Azure虚 ...

  6. vim中不能使用“+y拷贝

    新的机器上安装vim后可以使用yy复执,但是”+y拷贝到系统剪切板不行.按下面操作解决: 1.首先要检查你的vim版本是否支持+clipboard,命令是:version 或者可以输入:reg 查看是 ...

  7. shell脚本应用(5)--实用脚本片段

    校验参数 if [ "$#" -ne 1 ] then echo "Incorrect number of arguments" echo "Usag ...

  8. Linux经久不衰的应用程序

    Linux里面的应用程序一贯以高安全性,高性价比(功能/所占空间),此次记录一下Linux里面比较常用的而且经久不衰的应用程序. Shell:               bash(它结合了 csh ...

  9. 局域网接入Internet

    说在前面的话 局域网接入Internet的方式多样: 有1传统的Modem(调制解调器)拨号接入,费用低廉的2 ISDN和 3 ADSL接入,费用较高的4 DDN专线接入,5 Cable Modem高 ...

  10. JQuery- 解析JSON数据

    我们先以解析上例中的comments对象的JSON数据为例,然后再小结jQuery中解析JSON数据的方法.上例中得到的JSON数据如下,是一个嵌套JSON: {,,"nickname&qu ...