最小公倍数 【杭电-HDOJ-1108】 附题+具体解释
2024-09-24 05:51:43
/*
最小公倍数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32933 Accepted Submission(s): 18398
Problem Description
给定两个正整数,计算这两个数的最小公倍数。
Input
输入包括多组測试数据,每组仅仅有一行,包括两个不大于1000的正整数.
Output
对于每一个測试用例,给出这两个数的最小公倍数,每一个实例输出一行。
Sample Input
10 14
Sample Output
70
*/
#include<stdio.h> //递归思想
int swap(int a,int b)
{
if(a>b)
{
return !b?
a:swap(b,a%b);
}
else if(a<b)
{
return !a?b:swap(a,b%a);
}
else return a;
}
int main()
{
int a,b;
while(~scanf("%d %d",&a,&b))
{
printf("%d\n",a*b/swap(a,b));
}
return 0;
}
最新文章
- Image模块
- CentOS6上无法启动NFS服务
- Windows Azure Virtual Machine (31) 迁移Azure虚拟机
- Overlay network 覆盖网络
- Redis基础知识之—— 5个必须了解的事情【★★★★★】
- CodeColorer支持的语言
- Why are very few schools involved in deep learning research? Why are they still hooked on to Bayesian methods?
- 【原创】Java移位运算
- 20151217jquery学习笔记--注册表单
- Vim及VimScript资料总结《转载》
- 学习javascript基础知识系列第三节 - ()()用法
- hosts文件导致无法访问网站
- python3.x中如何实现print不换行
- Images as x-axis labels
- java集合相关问题
- HASHSET不能预留容量问题
- 【原创】深入理解c++的右值引用
- Ubuntu 12.04上安装Hadoop并运行
- grid - 网格轨道最小和最大尺寸
- 【做题】apc001_f-XOR Tree——巧妙转化及dp
热门文章
- ElasticSearch Mapping中的字段类型
- Java中的对象池技术
- hdu 5592 ZYB&#39;s Premutation (权值线段树)
- BZOJ 2733 [HNOI2012]永无乡(启发式合并+Treap+并查集)
- [NOIp2016提高组]愤怒的小鸟
- 将json字符串转换成list<;T>;
- Codeforces Round #344 (Div. 2) D. Messenger kmp
- Android Logcat Security(转)
- 如何ping测有端口的网站
- countdownlatch用法