ZOJ1003 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: 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 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

题目大意就是有两个人报数字,一个人报大,一个人报小,所报的都不知道真假,但是小的那个人可以质疑大的,如果质疑成功了,且小的是真的则小的赢,否则就大的赢。
规则:有编号为1-100的小球,每个人的分数即为所取得的小球编号相乘(小球编号不重复),最后各自报出自己的分数。
题目规定每次小的都会质疑大的。
质疑的过程:如果大的数的因子(即气球)在小的数的因子(即气球)中出现过的话,则可辨别出大的说谎(因为气球只有一个,小的优先)。如果大的数的因子都没有在小的数的因子中出现的话,即大的赢(无论所报的数是真的还是假的),否则小的赢。
总结:小赢的情况:小的数是真的且大的数是假的。否则都是大的赢。

本题要用到DFS遍历所有因子。

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
bool flag1,flag2;//大的数flag1,小的flag2
void dfs(int big,int small,int k)
{
    
    if(small==1)//小数的气球都找完了
    {
        flag2=true;//小数的是真的
        if(big==1)//如果在小数的因子都找完的情况下,大数的也能到1,则大数也是真的
            flag1=true;
    }
    if(k<2||(flag1&&flag2))//如果都是是真的话就没必要在往下搜索了
        return;
    //下面相当于建立分支,小的用,大的用,大小都不用
    if(small%k==0)//先让小的用气球
        dfs(big,small/k,k-1);
    if(big%k==0)//再让大的用
        dfs(big/k,small,k-1);
    dfs(big,small,k-1);//都用不到就看下一个气球
}
int main()
{
    int a,b;
    while(cin>>a>>b){
    if(a<b)
        swap(a,b);//交换数值
        flag1=false;
        flag2=false;
        dfs(a,b,100);
        if(!flag1&&flag2)cout<<b<<endl;
        else cout<<a<<endl;
    }
    return 0;
}


HFSS 3D LAOUT PCB 裁剪,差分线,过孔仿真和优化 我本身不是做天线设计的,所以HFSS这个软件给我主要还是做PCB级别的高速信号完整性仿真,一般2.5D的仿真软件无法对过孔和跨平面进行仿真。所以要借助三维电磁软件进行。今天就针对PCB进行裁剪。为什么要裁剪?以为如果把整个PCB一起仿真的话,应该要好几个月吧。所以为了加快仿真速度,必须进行裁剪仿真。①candence的PCB可以直接导入。那么先导入brd文件,file-import-candence结果如下②点击cutout,选中要仿真的net和参考平面。这里最好选creat new不然会把原文件覆盖掉。注 阅读详情

相关推荐

Win11内核隔离无法打开的解决方案详解

内核隔离问题的解决需遵循"先硬件后软件"的排查原则,90%以上的案例可通过驱动清理或外设断开解决。对于必须禁用该功能的用户,建议定期使用Windows Defender进行全盘扫描,并保持系统更新至最新版本。技术决策需在安全性和兼容性之间取得平衡,本文提供的多维解决方案可帮助用户构建更稳定的Windows 11使用环境。

mmoo_python的博客 4825

ZOJ Problem Set - 1003Crashing Balloon

Crashing BalloonTime Limit: 1 Second      Memory Limit: 32768 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 ...

weixin_34384557的博客 219

ROS牛耕法全覆盖规划:从算法原理到清洁机器人实战解析

本文深入解析ROS牛耕法全覆盖规划算法在清洁机器人中的应用,从算法原理到实战优化技巧全面覆盖。详细介绍了地图预处理、区域分解和路径优化等关键步骤,并分享实际案例中的解决方案,帮助开发者提升机器人清扫效率和覆盖率。

weixin_27013291的博客 391

zju 1003 zoj 1003

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 th

sonfree的专栏 661

FreeSWITCH彩铃与回铃音区别详解:从183/180信令到mod_da2检测模块

本文深入解析FreeSWITCH中彩铃与回铃音的技术差异,从183/180信令机制到mod_da2智能检测模块的实现原理。通过对比SIP协议中的早期媒体传输、回铃音补偿技术及实战案例,帮助开发者掌握VoIP系统中的关键音频处理技术,提升呼叫系统稳定性和用户体验。

tree8的博客 348

Axure原型模板与元件库APP交互设计素材(附资料)

在Axure中,手机模型是展示APP或小程序界面效果的重要工具。通过导入手机模型元件,设计师可以更加直观地模拟真实设备的显示效果,从而更准确地评估设计的可行性和用户体验。Axure官方及第三方资源库中提供了多种品牌和型号的手机模型,如iPhone、Android等,设计师可以根据项目需求选择合适的模型进行使用。Axure作为一款强大的原型设计工具,为APP和小程序的设计与开发提供了丰富的界面组件元件库和交互设计素材。

招风的黑耳优快云 1980

[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

55、宇宙微波背景辐射望远镜及其光学系统解析

本文详细解析了宇宙微波背景辐射(CMB)望远镜及其光学系统的设计与优化。内容涵盖折射与反射光学系统的特性、旁瓣控制技术、气球与地面观测系统的对比、探测器阵列的发展、光学系统设计流程以及不同观测场景下的光学系统选择。同时,文章展望了CMB望远镜光学系统的未来发展趋势,包括技术创新、多频段观测、国际合作与大型项目等。通过系统性的分析与对比,为CMB研究提供了全面的技术支持与理论基础。

f9g0h的博客 142

zoj1003 Crashing Balloon

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

fairylan的专栏 1408

ubuntu22.04下对使用linuxdeployqt发布的qt程序进行deb打包操作

【代码】ubuntu22.04下对使用linuxdeployqt发布的qt程序进行deb打包操作。

十三阿哥的博客 1402

基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的农作物害虫检测系统(深度学习模型+UI界面+训练数据集)

随着人工智能技术在农业领域的深入应用,基于深度学习的害虫检测系统已成为智慧农业的重要组成部分。本文详细介绍了一种基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的农作物害虫检测系统,涵盖算法原理、数据集构建、模型训练、系统实现及完整代码。该系统能够实时检测并识别多种农作物害虫,为农业生产提供精准的病虫害监测解决方案。

YOLO 273

ZOJ 1003 Crashing Balloon

每年的六一儿童节,电视上都会播放“撞气球”游戏。规则很简单,地上放着100个气球,上面标着1到100的数字。裁判喊“开始!”后,两名选手开始用脚撞气球,同时将自己的分数乘以撞到气球上的数字。一分钟后,小观众们可以把剩下的气球拿走,每个选手报告自己的得分,即撞到气球上的数字的乘积。宣布得分最高的选手就是非正式的获胜者。然而,争议不可避免地会出现,因此在争议解决之前,官方不会确定获胜者。声称得分较低的玩家有权挑战对手的得分。

wuqingshun314159的博客 1053

华为OD机试真题 新系统2026-04-01 C语言 实现【空间占用计算】

员工A的磁盘空间经常被耗尽,他需要找到占用空间最大的目录或文件,然后决定如何清理文件释放空间。给定某一目录,请编写程序帮助他统计该目录内一级子目录和文件的占用空间,并返回目标目录一级子项(文件或子目录)中占用空间最大的项。

MISAYAONE的博客 230

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

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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 720

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Crashing Balloon ZOJ1003

每年6月1日儿童节,电视上都会播放一个名为“撞气球”的游戏。规则非常简单。地面上有 100 个贴有标签的气球,编号为 1 到 100。在裁判喊道“我们走吧!”之后。两个玩家,每人都以“1”的分数开始,竞相用脚撞气球,同时将他们的分数乘以他们撞坏气球上的数字。一分钟后,让小观众把剩下的气球拿走,每位参赛者报告他她的分数,他她撞到的气球上的数字的乘积。非官方获胜者是宣布最高分的玩家。 但是,不可避免地会出现争议,因此在争议解决之前,无法确定正式获胜者。声称得分较低的玩家有权挑战他/她的对手的得分。分数较低的玩家

具身机器人和通用AI 653

ZOJ 1003 Crashing Balloon 搜索

题意:100个气球,气球上标有1-100的号码,每踩一个气球,则自己的得分可以乘以该气球的标号(初始得分为1,每个气球只能踩一次)。 题解:假如a>b,求出a,b所有可能的分解情况(分解为1-100的数的乘积)。然后比对,只要存在一种分解情况,使得a的因子中不含b的因子,a就是可能的。 #include #include #include #include using namespace

2965

ZOJ-1003-Crashing Balloon

#include <stdio.h> using namespace std; bool aTrue, bTrue; //a false, b true, then b true //a true, b true, then a true; //b false then a true; void Judge(int a, int b, int p){ if(aTrue) ret...

lengyudota的博客 235
上一篇: ZOJ1002 Fire Net DFS(深度优先搜索) 已AC
下一篇: POJ2106 Boolean Expressions / Openjudge Boolean Expressions (递归)全局题号1108
Link_Ray
博客等级 码龄9年 44粉丝 156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值