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

问题链接:ZOJ1003 Crashing Balloon
问题简述:(略)
问题分析
    先占个位置,暂时不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* ZOJ1003 Crashing Balloon */#include <iostream>
#include <stdio.h>using namespace std;bool aflag, bflag;
void judge(int m, int n, int p)
{if(aflag)return;if(m == 1 && n == 1) {aflag = true, bflag = true;     // 找到不同因子return;}if(n == 1)bflag = true;if(p > 1) {if(n % p == 0) judge(m, n / p, p - 1);      // 先分解小的if(m % p == 0) judge(m / p, n, p - 1);judge(m, n, p - 1);}
}int main()
{int a, b;while(~scanf("%d%d", &a, &b)) {if(a < b) swap(a, b);aflag = false, bflag = false;judge(a, b, 100);if(aflag || !bflag)printf("%d\n", a);elseprintf("%d\n", b);}return 0;
}

ZOJ1003 Crashing Balloon【水题】相关推荐

  1. 【算法】算法之美—Crashing Balloon

    题目概述:Crashing Balloon On every  June 1st, the Children's Day, there will be a game named "crash ...

  2. 【Acm】算法之美—Crashing Balloon

    题目概述:Crashing Balloon On every  June 1st, the Children's Day, there will be a game named "crash ...

  3. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  4. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  5. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  6. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  7. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  8. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  9. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

最新文章

  1. SimCSE:用于句子嵌入的对比学习
  2. linux系统12,Linux操作系统12则经典应用技巧
  3. vlc windows 编译文档
  4. 指针常量 和 指向常量的指针区别
  5. java学jdk几_Java系列学习(一)-JDK下载与安装
  6. 答CSDN关于建模的系列问题
  7. java操作redis并发_使用Redis incr解决并发问题的操作
  8. 三菱伺服自动调谐_自动化领域最值得关注的十大伺服电机
  9. IE6下透明PNG图片的显示
  10. POJ NOI MATH-7657 连乘积末尾0的个数
  11. 类中不写成员函数易犯错误模型
  12. 支持向量机总结(SVM)
  13. 错别字检测的软件有哪些?自动检查错别字的工具 文字校对 文本纠错 查错别字 校对软件 错别字检查 论文格式 在线校对
  14. 【命学释疑之何为命】一个程序员对算命的剖析
  15. SuperMap iDesktop商场选址分析
  16. 修改html会影响seo,网站修改css影响seo吗?
  17. CollapsingToolbarLayout 标题字体及颜色设置
  18. 如何给注册中心锦上添花?
  19. RTX4060参数 RTX4060功耗 RTX4060 显卡性能
  20. Java中的.length与.length()

热门文章

  1. golang之正则校验(验证某字符串是否符合正则表达式)
  2. Golang1.8新特性展望及2016发展回顾
  3. Box2D物理引擎的使用方法
  4. 【STL】List基础
  5. java共享内存_Java共享内存
  6. Rxjava2+Retrofit2结合使用
  7. Doris之Rollup 与查询
  8. Hadoop—SequenceFile文件的数据格式(1)
  9. 关掉magiskhide_最新版Magisk-v20.4刷入后找不到Magisk Hide怎么办+Magisk Hide开启教程
  10. python抓取教学_Python Selenium 实战教学:爬取每日天气