ACM/ICPC ZOJ1003-Crashing Balloon 解题代码
- #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 解题代码的更多相关文章
- ACM/ICPC ZOJ1006-Do the Untwist 解题代码
#include <iostream> #include <string> #include <stdlib.h> using namespace std; int ...
- ZOJ1003 Crashing Balloon
Crashing Balloon Time Limit: 2 Seconds Memory Limit: 65536 KB On every June 1st, the Children's ...
- 2013 ACM/ICPC 成都网络赛解题报告
第三题:HDU 4730 We Love MOE Girls 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4730 水题~~~ #include < ...
- hdu 4762 && 2013 ACM/ICPC 长春网络赛解题报告
这次的答案是猜出来的,如果做得话应该是应该是一个几何概型的数学题: 答案就是:n/(m^(n-1)); 具体的证明过程: 1.首先枚举这M个点中的的两个端点,概率是:n*(n-1); 2.假设这个蛋糕 ...
- hdu 4763 && 2013 ACM/ICPC 长春网络赛解题报告
一个KMP的简单题 不过好久没用过这个东东了,今天写的时候花了很多时间: 只需要花点时间判断下所有的元素都相同的的情况就行了! #include<cstdio> #include<c ...
- 【Acm】算法之美—Crashing Balloon
题目概述:Crashing Balloon On every June 1st, the Children's Day, there will be a game named "crash ...
- 【ZOJ1003】Crashing Balloon(DFS)
Crashing Balloon Time Limit: 2 Seconds Memory Limit: 65536 KB On every June 1st, the Children's ...
- 【转】lonekight@xmu·ACM/ICPC 回忆录
转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...
- 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 ...
随机推荐
- EventHandlerList z
写一个类时,有时候会在同一个类上添加很多事件,事件很多的话,是不容易管理的,.NET提供的EventHandlerList可以辅助多个事件的管 理,但不方便的地方是,它不是类型安全的,缺少类型安全,多 ...
- oracle logminer全解析
今天写篇原创的,把在工作中遇到的logminer问题总结下 (1)简介: logminer 工具即可以用来分析在线,也可以用来分析离线日志文件,即可以分析本身自己数据库的重作日志文件,也可以用来分析其 ...
- 支持度(support)和置信度(confidence)
支持度(Support)的公式是:Support(A->B)=P(A U B).支持度揭示了A与B同时出现的概率.如果A与B同时出现的概率小,说明A与B的关系不大:如果A与B同时出现的非常频 ...
- Clean Code – Chapter 6 Objects and Data Structures
Data Abstraction Hiding implementation Data/Object Anti-Symmetry Objects hide their data behind abst ...
- 使用Windows Azure创建Linux系统虚拟机-上
创建虚拟机来运行Linux 当您在Azure管理门户中使用映像图库时,创建运行Linux的虚拟机很容易.本指南告诉您如何做到这一点,假设你没有使用过Azure. 注意: 即使你不需要使用过Azure虚 ...
- vim中不能使用“+y拷贝
新的机器上安装vim后可以使用yy复执,但是”+y拷贝到系统剪切板不行.按下面操作解决: 1.首先要检查你的vim版本是否支持+clipboard,命令是:version 或者可以输入:reg 查看是 ...
- shell脚本应用(5)--实用脚本片段
校验参数 if [ "$#" -ne 1 ] then echo "Incorrect number of arguments" echo "Usag ...
- Linux经久不衰的应用程序
Linux里面的应用程序一贯以高安全性,高性价比(功能/所占空间),此次记录一下Linux里面比较常用的而且经久不衰的应用程序. Shell: bash(它结合了 csh ...
- 局域网接入Internet
说在前面的话 局域网接入Internet的方式多样: 有1传统的Modem(调制解调器)拨号接入,费用低廉的2 ISDN和 3 ADSL接入,费用较高的4 DDN专线接入,5 Cable Modem高 ...
- JQuery- 解析JSON数据
我们先以解析上例中的comments对象的JSON数据为例,然后再小结jQuery中解析JSON数据的方法.上例中得到的JSON数据如下,是一个嵌套JSON: {,,"nickname&qu ...