zoj-1003
来源:互联网 发布:淘宝买药可靠吗 编辑:程序博客网 时间:2024/05/22 00:22
#include <iostream>
using namespace std;
void Dfs(int to,long int numa,long int numb);
int flagA,flagB;
int main()
{
long int numA,numB;
while(cin >> numA >> numB)
{
if(numA < numB)
swap(numA,numB);
flagA=0;
flagB=0;
Dfs(100,numA,numB);
if(flagA)
cout << numA << endl;
else
{
if(flagB)
cout << numB << endl;
else
cout << numA << endl;
}
}
return 0;
}
void Dfs(int to,long int numa,long int numb)
{
if(numb==1)
{
flagB=1;
if(numa==1)
flagA=1;
}
if(to==1 || flagA==1 && flagB==1)
return ;
if(numa%to==0)Dfs(to-1,numa/to,numb);
if(numb%to==0)Dfs(to-1,numa,numb/to);
Dfs(to-1,numa,numb);
}
using namespace std;
void Dfs(int to,long int numa,long int numb);
int flagA,flagB;
int main()
{
long int numA,numB;
while(cin >> numA >> numB)
{
if(numA < numB)
swap(numA,numB);
flagA=0;
flagB=0;
Dfs(100,numA,numB);
if(flagA)
cout << numA << endl;
else
{
if(flagB)
cout << numB << endl;
else
cout << numA << endl;
}
}
return 0;
}
void Dfs(int to,long int numa,long int numb)
{
if(numb==1)
{
flagB=1;
if(numa==1)
flagA=1;
}
if(to==1 || flagA==1 && flagB==1)
return ;
if(numa%to==0)Dfs(to-1,numa/to,numb);
if(numb%to==0)Dfs(to-1,numa,numb/to);
Dfs(to-1,numa,numb);
}
- zoj 1003
- zoj-1003
- zoj-1003
- zoj 1003
- zoj 1003
- ZOJ 1003
- ZOJ 1003
- ZOJ 1003
- ZOJ 1003
- zju 1003 zoj 1003
- [ZOJ] 1003 Crashing Balloon
- zoj 1003 Crashing Balloon
- ZOJ 1003 Crashing Balloon
- zoj 1003 Crashing Balloon
- ZOJ 1003 Crashing Balloon
- zoj 1003 Crashing Balloon
- zoj 1003 Crashing Balloon
- zoj 1003 Crashing Balloon
- MFC 获得当前程序目录 当前绝对路径
- zoj1006
- 2013年近期免费VPN申请指南
- ArcEngine读取数据(数据访问)
- 北漂们,2013好好混
- zoj-1003
- 前景检测方面的研究
- 数据机构-四种链表
- angularJS开发指南(angularJS developer guide) 之二
- 杭电2025
- 进程与线程的一个简单解释
- Android应用开启图片加载和防止图片解析溢出的小例子
- A survey on the communication architectures in smart grid(2)
- 关于百度地图显示自己的位置