#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; int n,m; int flag1,flag2; void dfs(int a,int b,int x)
{
if(b==)
{
flag2=;
if(a==) flag1=;
}
if(flag1&&flag2) return;
if(x==) return; if(a%x==) dfs(a/x,b,x-);
if(b%x==) dfs(a,b/x,x-);
dfs(a,b,x-);
} int main()
{
while(~scanf("%d%d",&n,&m))
{
if(n<m) swap(n,m);
flag1=,flag2=;
dfs(n,m,);
if(flag1==&&flag2==) printf("%d\n",m);
else printf("%d\n",n);
}
return ;
}

ZOJ 1003 Crashing Balloon的更多相关文章

  1. [ZOJ 1003] Crashing Balloon (dfs搜索)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3 题目大意:给你a,b两个数,问当b由约数1到100组成时,a能否由其 ...

  2. [ZJU 1003] Crashing Balloon

    ZOJ Problem Set - 1003 Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every J ...

  3. 1003 Crashing Balloon

    考察DFS的应用,判断两个数的因子. #include <stdio.h> int f1,f2; void DFS(int m,int n,int k){ ){ f2=; ) f1=; } ...

  4. ZOJ1003 Crashing Balloon

    Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's ...

  5. 【ZOJ1003】Crashing Balloon(DFS)

    Crashing Balloon Time Limit: 2 Seconds      Memory Limit: 65536 KB On every June 1st, the Children's ...

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

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

  7. ZJU-1003 Crashing Balloon dfs,

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3 题意(难以描述):A,B两个人从1~100选数乘起来比谁的大(不能选重复的或者 ...

  8. ZOJ 3981:Balloon Robot(思维+递推)

    题目链接 题意 有n支队在m个位置上做题,有一个机器人位置1到位置m再到位置1循环走派发气球,当队伍a在时间b做完了一道题目的时候,假如机器人走到队伍a的位置的时间为c,那么这个队伍的不开心值就是c- ...

  9. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

随机推荐

  1. 【翻译】Asp.net Core介绍

    ASP.NET Core is a significant redesign of ASP.NET. This topic introduces the new concepts in ASP.NET ...

  2. 【算法专题】工欲善其事必先利其器—— C++ STL中vector(向量/不定长数组)的常用方法总结

    #include<iostream> #include<cstdio> #include<string> #include<vector>//不定长数组 ...

  3. 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)

    队名:Unlimited Code Works(无尽编码)  队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...

  4. 微信小程序-video详解

    在小程序火热的今天,作为IT行业的一员,我也来凑了一下热闹,话不多说了,接下来看看视频上传,和跨页面获取值的相关案例吧!! 视频上传部分代码: 视频播放 随机颜色的产生: 颜色页面的选择:

  5. sellenium页面元素的定位方法

    1.findElements函数可用于多个元素定位 (1)使用ID定位:driver.findElement(By.id("ID值")); 例:HTML代码: 定位语句代码:Web ...

  6. Netty(7)源码-ByteBuf

    一.ByteBuf工作原理 1. ByteBuf是ByteBuffer的升级版: jdk中常用的是ByteBuffer,从功能角度上,ByteBuffer可以完全满足需要,但是有以下缺点: ByteB ...

  7. one hot encoding

    转自:http://blog.sina.com.cn/s/blog_5252f6ca0102uy47.html 问题由来 在很多机器学习任务中,特征并不总是连续值,而有可能是分类值. 例如,考虑一下的 ...

  8. hdu 1536 S-Nim (简单sg函数)

    题意:首先输入K 表示一个集合的大小  之后输入集合 表示对于这对石子只能去这个集合中的元素的个数 之后输入 一个m 表示接下来对于这个集合要进行m次询问 之后m行 每行输入一个n 表示有n个堆  每 ...

  9. 引用Excel.dll 时找不到类型怎么办

    将引用(Microsoft.Office.Interop.Excel)的属性"嵌入互操作类型"由True修改为False即可

  10. mysql连接失败或出现“Too many connections”错误

    mysql连接失败或出现"Too many connections"错误 # 按自己服务器的配置文件路径修改 vi /etc/my.cnf 查找:max_connections 修 ...