ZOJ 1003 Crashing Balloon

ZOJ-1003-Crashing-Balloon 题目描述 On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground there are 100 labeled balloons, with the numbers 1 to 100. After the referee shouts “Let’s go!” the two players, who 阅读详情
Crashing Balloon
Time Limit: 2000 msMemory Limit: 65536 KB

On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled balloons, with the numbers 1 to 100.  After the referee shouts "Let's go!" the two players, who each starts with a score of  "1", race to crash the balloons by their feet and, at the same time, multiply their scores by the numbers written on the balloons they crash.  After a minute, the little audiences are allowed to take the remaining balloons away, and each contestant reports his\her score, the product of the numbers on the balloons he\she's crashed.  The unofficial winner is the player who announced the highest score.

Inevitably, though, disputes arise, and so the official winner is not determined until the disputes are resolved.  The player who claims the lower score is entitled to challenge his\her opponent's score.  The player with the lower score is presumed to have told the truth, because if he\she were to lie about his\her score, he\she would surely come up with a bigger better lie.  The challenge is upheld if the player with the higher score has a score that cannot be achieved with balloons not crashed by the challenging player.  So, if the challenge is successful, the player claiming the lower score wins.

So, for example, if one player claims 343 points and the other claims 49, then clearly the first player is lying; the only way to score 343 is by crashing balloons labeled 7 and 49, and the only way to score 49 is by crashing a balloon labeled 49.  Since each of two scores requires crashing the balloon labeled 49, the one claiming 343 points is presumed to be lying.

On the other hand, if one player claims 162 points and the other claims 81, it is possible for both to be telling the truth (e.g. one crashes balloons 2, 3 and 27, while the other crashes balloon 81), so the challenge would not be upheld.

By the way, if the challenger made a mistake on calculating his/her score, then the challenge would not be upheld. For example, if one player claims 10001 points and the other claims 10003, then clearly none of them are telling the truth. In this case, the challenge would not be upheld.

Unfortunately, anyone who is willing to referee a game of crashing balloon is likely to get over-excited in the hot atmosphere that he\she could not reasonably be expected to perform the intricate calculations that refereeing requires.  Hence the need for you, sober programmer, to provide a software solution.

Input

Pairs of unequal, positive numbers, with each pair on a single line, that are claimed scores from a game of crashing balloon.

Output

Numbers, one to a line, that are the winning scores, assuming that the player with the lower score always challenges the outcome.

Sample Input

343 49
3599 610
62 36

Sample Output

49
610
62
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<iomanip>
using namespace std;
 
int n, m;
bool flagA, flagB;
 
void dfs(int n,int m,int k){
	if (n == 1 && m == 1){
		flagA = true;
		flagB = true;
		return;
	}
	if (m == 1){
		flagB = true;
	}
	for (int t = k + 1; t <= 100; t++){
		if (n%t == 0){
			dfs(n/t,m,t);
			if (flagA) return;
		}
		if (m%t == 0){
			dfs(n, m / t,t);
			if (flagA) return;
		}
	}
}
 
int main(){
	while (cin >> n >> m){
		if (n < m){
			swap(n, m);
		}
		flagA = false;
		flagB = false;
		dfs(n,m,1);
		int res = n;
		if (flagA == false && flagB == true){
			res = m;
		}
		cout << res << endl;
	}
	return 0;
}

ZOJ1003 Crashing Balloon NULL 博文链接:https://weitch.iteye.com/blog/1007144 立即下载

相关推荐

GNSS/INS松组合导航实战:如何用卡尔曼滤波提升定位精度(附MATLAB代码)

本文深入探讨了GNSS/INS松组合导航的工程实践,详细阐述了如何利用卡尔曼滤波算法融合卫星与惯性数据以提升定位精度。内容涵盖从仿真环境搭建、误差状态卡尔曼滤波器(ESKF)设计,到状态与观测方程实现、噪声参数调试及常见问题排查的全过程,并提供了可直接运行的MATLAB代码,为开发高精度、鲁棒的组合导航系统提供实战指南。

weixin_29057163的博客 166

1003.Crashing Balloon

原题描述: On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled balloons, with the numbers 1 to 100.

CC 485

QCC308X/518X/309X加LDAC解码

QCC308X/518X/309X加LDAC解码。

Alex_886的博客 6614

浙大ZOJ 1003 Crashing Ballon问题解决及其他人的做法

完成了在ZOJ上的处女题,小兴奋,在此记录一下: 一、工程代码加上算法设计注释 --------------------------------------------------crash_ballon.h---------------------------------------------- #ifndef JLU_CCST_GDC_CRASH_BALLON_H #define J

xiaogugood的专栏 3666

vivado 工程修改芯片型号

vivado工程芯片与实际板子不匹配时,需要修改工程的芯片型号,并对原工程的ip进行同步更新,之后生成新的bit文件,烧录到板子中

k7126685的博客 1万+

Opencascade 保存点云为 .stp 和 .step 格式

总结一下,OpenCascade提供了强大的功能和工具,使我们能够方便地将点云数据保存为 .stp 和 .step 格式。通过使用类似于上述示例代码的方法,你可以使用OpenCascade库将点云数据保存为.STP和.STEP格式。总结一下,使用OpenCascade库,你可以方便地将点云数据保存为.STP和.STEP格式。通过使用类似于上述示例代码的方法,你可以将点云数据转换为OpenCascade的几何模型,并将其保存为所需的文件格式。请注意,上述代码仅涵盖了将点云数据保存为.STP格式的基本步骤。

CwzCode的博客 1158

一道挺麻烦的深度优先搜索题

题目:ZOJ 1003 Crashing Balloon题目意思是:踩气球比赛,1-100个气球,两个人上去踩,踩完以后把各自踩的所有气球的编号相乘,然后两个人分别报一个数。报小的数的我们称为挑战者,然后叫你判断他们说的是真话还是假话。若两人都说真话,那大数的胜。如果两人都说假话,那还是大数的胜。若小的说真话,大的说假话,那小的胜,即挑战者胜。比如:一个人说343,另一个说49,那就报49的人胜。因为343 = 7 * 49,而只有一个49号气球,所以算挑战者说真话,另外一个人说假话。算法效率不是高,关键是

chyshnu的专栏 1052

PCL体素滤波器【2026最新版】

PCL实现的VoxelGrid类和ApproximateVoxelGrid体素滤波,详细记录。博客长期更新,本文最近一次更新时间为:2026年3月14日。

点云侠的博客 39万+

Crashing Balloon因子的计算

碰撞气球 时间限制:2秒内存限制:65536 KB 每年6月1日的儿童节,都会有一个名为“爆气球”的电视节目。这个规则很简单。地面上有100个标有气球的气球,号码是1到100。裁判员喊道:“走吧!”这两名选手每人以1分开始比赛,用脚撞倒气球,同时把他们的分数乘以写在气球上的数字。一分钟后,小观众就可以把剩下的气球拿走,每个参赛者都会报告他自己的得分,即他坠毁的气球上的数字。非正式的赢家是宣...

qq_42728686的博客 540

【华为OD机试真题 新系统】960、 面试叫号系统 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)

【华为OD机试真题 2026C卷】960、 面试叫号系统 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2025e卷,od机试,2025E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2025华为od,如何备战华

KJ.JK 2363

innovus: 如何让两个generate clock balance skew group?

如题,在sdc约束中两个generate clock被设置到同一个clock group中,工具虽然会生成对应的两个skew group,但是阅读ccoot_spec发现工具并没有让两个skew group进行balance,这时就需要手动设置balance skew group。我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 4051

zoj 1003 Crashing Balloon(整数分解应用)

Crashing Balloon Time Limit: 2 Seconds Memory Limit: 65536 KB On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV. The rule is very sim...

weixin_30819085的博客 286

【Windows Server 2019】发布服务器 | 远程桌面服务的安装与配置 Ⅰ——理论,实验拓扑和安装基于RemoteAPP的RDS

博客介绍了Windows Server中远程桌面服务的理论,实验拓扑以及基于RemoteAPP的RDS安装。博文介绍了如何在Windows Server上部署发布服务器。

VMware, Windows, Linux, Cisco, Container, Kubernetes, Kali 6130

[ZOJ] 1003 Crashing Balloon

/*-----------------------------------------  zoj1003 Crashing Balloon  road 2007/08/31     dfs     --------------------------------------------*/#include #include #define SWAP(x,y) do { x = x^y; y =

roadtang的专栏 999

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

zoj1003 Crashing Balloon

//zoj1003 Crashing Balloon //Accepted 1003 C++ 00:00.06 440K #include #include using namespace std; i

fairylan的专栏 1410

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

ZOJ:1003 Crashing Balloon(DFS)

On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground there are 100 labeled balloons, with the numbers 1 to 100. After the referee shouts “Let’s go!” the two players, who each

Rrrrya 392

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

ZOJ1003 Crashing Balloon【水题】

Crashing Balloon Time Limit: 2 Seconds Memory Limit: 65536 KB On every June 1st, the Children’s Day, there will be a game named “crashing balloon” on TV. The rule is very simple. On the ground...

海岛Blog 722
上一篇: ZOJ1002 Fire Net
下一篇: ZOJ1004Anagrams by Stack
Lycodeboy
博客等级 码龄11年 1170粉丝 142原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值