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 ...
随机推荐
- How to get FlowLayoutPanel.AutoSize to work with FlowBreak
have a problem with a FlowLayoutPanel and I don't know how to solve it. I'm placing two FlowLayoutPa ...
- POJ 1511 Invitation Cards dij
分析:正向加边,反向加边,然后两遍dij #include<cstdio> #include<cstring> #include<queue> #include&l ...
- Bootstrap之表格checkbox复选框全选 [转]
转自: http://blog.csdn.net/shangmingchao/article/details/49761315 效果图: HTML中无需添加额外的一列来表示复选框,而是由JS完成,所以 ...
- 【libsvm学习】
参考: http://www.cnblogs.com/bigshuai/articles/2883256.html http://www.cnblogs.com/tornadomeet/archive ...
- Cocos2d-x v3.3 lua绑定c++类方法总结
网上有很多cocos2d-x lua绑定c++类的接口教程,这篇文章也是总结他们的经验. 其中重点参考了 http://cn.cocos2d-x.org/tutorial/show?id=1295, ...
- javaweb之Java基础加强
1.myeclipse的安装和使用 * eclipse:是一个免费的开发工具 * myeclipse:是一个收费的插件,破解myeclipse, ** 安装目录的要求: 不能有中文和空格 ** 安装完 ...
- ARP局域网欺骗工具编写
每台主机都设有一个ARP高速缓存(ARP cache),里面有本局域网上各主机和路由器的IP地址和硬件地址的映射表,这些都是该主机目前知道的一些地址. 当主机A要向本局域网上的某个主机B发送IP数据报 ...
- WordPress更新服务加快收录
WordPress更新服务的设置在后台"设置"-"撰写".更新服务下的文本框中默认为http://rpc.pingomatic.com/.该地址网站Ping-o ...
- HW4.45
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...
- Java NIO 缓冲技术详解
缓冲区(buffer)是从即将写入通道(channel)或刚刚从通道中读出的一段数据.它是一个持有数据,并扮演NIO通道端点的对象.缓冲区为数据访问和读写过程提供正式机制. 它是NIO和老版Java ...