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 ...
随机推荐
- North North West
North North West Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:65536KB Total submit ...
- [Andrew]Grid列编辑实现
Html.X().GridPanel() .Plugins(Html.X().CellEditing()) .Listeners(l =&g ...
- Ubuntu 14.04 SSH + 远程登录xrdp
1. 安装ssh 打开"终端窗口",输入"sudo apt-get install openssh-server"-->回车-->输入"y ...
- 如何在编译Xcode-Plugin工程的时候增加Cocoapods依赖
关于如何在编译Xcode-Plugin工程的时候增加Cocoapods依赖 以及在Mac App上使用Cocoapods的时候遇到Library not found for -lPods时的解决办法 ...
- A Tour of Go If with a short statement
Like for, the if statement can start with a short statement to execute before the condition. Variabl ...
- Laravle Introduction
Where To Start Learning a new framework can be daunting, but it's also exciting. To smooth your tran ...
- hdu 3724 Encoded Barcodes
Trie模板.把所有单词都用字典树存起来,然后给每个节点赋权值表示前缀到该节点出现了几次.然后直接查询就可以了. #include <algorithm> #include <ios ...
- jquery判断文本域长度
<div id="result">您还可以输入100字</div> <textarea name="content" id=&qu ...
- 算法之旅,直奔<algorithm>之十三 fill
fill(vs2010) 引言 这是我学习总结<algorithm>的第十三篇,fill是一个很好的初始化工具.大学挺好,好好珍惜... 作用 fill 的作用是 给容器里一个指定的范围 ...
- javascript-智能社-笔记
JavaScript是什么 JavaScript就是修改样式 编写JS的流程 布局:HTML+CSS 属性:确定要修改哪些属性 事件:确定用户做哪些操作(产品设计) 编写JS:在事件中,用JS来修改页 ...