GCD and LCM

Time Limit : 1 sec, Memory Limit : 65536 KB
Japanese version is here

GCD and LCM

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b (0 < a, b ≤ 2,000,000,000). You can supporse that LCM(a, b) ≤ 2,000,000,000.

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Output

For each data set, print GCD and LCM separated by a single space in a line.

Sample Input

8 6
50000000 30000000

Output for the Sample Input

2 24
10000000 150000000 水题不解释
 #include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream> using namespace std; typedef long long ll; int gcd(int x,int y) {
return y > ? gcd(y,x % y) : x;
}
int main() { int a,b;
while(~scanf("%d%d",&a,&b)) {
printf("%d ",gcd(a,b));
printf("%lld\n",(ll)a / gcd(a,b) * b);
} }

AIZU 0005的更多相关文章

  1. 【Aizu - 0005 】GCD and LCM

    GCD and LCM Descriptions: Write a program which computes the greatest common divisor (GCD) and the l ...

  2. 【python小练】0005

    第 0005 题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小. 首先,iphone5的分辨率是1136x640. if条件句判断横(纵)向是否大于对应的ipho ...

  3. python练习册0005

    第 0005 题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小. 本题用了几个os模块的命令, import os from PIL import Image p ...

  4. Aizu 0525 Osenbei 搜索 A

    Aizu 0525 Osenbei https://vjudge.net/problem/Aizu-0525 题目: IOI製菓では,創業以来の伝統の製法で煎餅(せんべい)を焼いている.この伝統の製法 ...

  5. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

  6. Swift教程_swift常见问题(0005)_完美解决Cannot override &#39;dealloc&#39;异常

    Swift教程_swift常见问题(0001)_CoreData: warning: Unable to load class named 'xxx' for entity 'xxx' Swift教程 ...

  7. Aizu 2249 & cf 449B

    Aizu 2249 & cf 449B 1.Aizu - 2249 选的边肯定是最短路上的. 如果一个点有多个入度,取价值最小的. #include<bits/stdc++.h> ...

  8. Sliding Window - The Smallest Window II(AIZU) && Leetcode 76

    http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_3_B For a given array a1,a2,a3,...,aNa1 ...

  9. Aizu - 2564 Tree Reconstruction 并查集

    Aizu - 2564 Tree Reconstruction 题意:一个有向图,要使得能确定每一条边的权值,要求是每个点的入权和出权相等,问你最少需要确定多少条边 思路:这题好像有一个定理之类的,对 ...

随机推荐

  1. 控制反转 (inversion of control)

    The inversion of control (IoC) pattern is abstract; it says that one should move dependency creation ...

  2. 《samba服务配置的文本》

    创建简单的samba服务器 samba  很少用于互联网 /大部分用于局域网  网页更新/ 首先看下你是否安装后了samba. rpm -qa | grep samba samba的简介 1)samb ...

  3. Mac支付宝插件风波

    1.前言 首先我喜欢看一些创业的书,很多书里都会有马云的身影,马云也算是对我有一定的影响,从而我对淘宝也产生了一定的好感.但是关于这次插件事情,我对阿里产生了一些排斥的心里作用.我并不想吐槽淘宝,也不 ...

  4. 【Qt】Qt之自定义界面(QMessageBox)【转】

    简述 通过前几节的自定义窗体的学习,我们可以很容易的写出一套属于自己风格的界面框架,通用于各种窗体,比如:QWidget.QDialog.QMainWindow. 大多数窗体的实现都是采用控件堆积来完 ...

  5. HTML5读取本地文件 FileReader API接口

    1.FileReader接口的方法 FileReader接口有4个方法,其中3个用来读取文件,另一个用来中断读取.无论读取成功或失败,方法并不会返回读取结果,这一结果存储在result属性中. Fil ...

  6. Android:自定义控件样式(Selector)

    前言 在开发一个应用程序过程中不可避免的要去修改组件的样式,比如按钮.输入框等.现在就看下如何通过Seletor实现样式的自定义.先看下简单的效果对比

  7. 百度云盘demo

  8. Azure Websites Migration Assistant

    这是一个IIS+Database的迁移工具, 可以参考 http://channel9.msdn.com/Shows/Azure-Friday/Azure-Websites-Migration-Ass ...

  9. Java中的main()方法详解

    在Java中,main()方法是Java应用程序的入口方法,也就是说,程序在运行的时候,第一个执行的方法就是main()方法,这个方法和其他的方法有很大的不同,比如方法的名字必须是main,方法必须是 ...

  10. Windows Phone中的图形渲染处理

    前言    这篇文章主要介绍Windows Phone中XAML的渲染处理过程,你可以根据下文中所提到的内容来优化现有的XAML页面,来提高页面渲染的性能. XAML的渲染包括以下两个阶段: 1. 光 ...