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. HashSet 读后感

    HashSet实现Set,是一个不能重复元素的集合,内部使用HashMap实现.因此具有HashMap的特性,如不保证元素插入的顺序,线程不安全,允许null.HashSet的元素就是内部HashMa ...

  2. 1. 走进java

    走进java 1.java简介 1.1 java分类: 1.2 开发包JDK 1.3.一处编译,到处运行的特点 2. 配置开发环境 3. java基本语法 3.1关键字和保留字 3.2 标识符命名规则 ...

  3. THREE.js代码备份——canvas_lines(随机点、画线)

    <!DOCTYPE html> <html lang="en"> <head> <title>three.js canvas - l ...

  4. 问题:LVM lvextend增加空间后,df查看还是原来空间

    1.LVM的调整空间大小: #lvextend -L +1300M /dev/mapper/ycgsstore_sdb-wmy #lvdisplay wmy ycgsstore_sdb -wi-ao- ...

  5. 《怎样实现通过shell脚本将用户踢出系统》

    下面是一个将用户踢出系统的脚本: #!/bin/bashread -p "input your username " userps aux | grep "^$user& ...

  6. PCB特征阻抗计算神器Polar SI9000安装及破解指南

    近年来,IC集成度的提高和应用,其信号传输频率和速度越来越高,因而在印制板导线中,信号传输(发射)高到某一定值后,便会受到印制板导线本身的影响,从而导致传 输信号的严重失真或完全丧失.这表明,PCB导 ...

  7. [C/C++]在头文件中使用static定义变量意味着什么

    文章出处:http://www.cnblogs.com/zplutor/ 看到有一位同学在头文件中这么写: static const wchar_t* g_str1 = - static const ...

  8. 匹配一级分类和二级分类 名字和url 里面有玄机

    1:要匹配的html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...

  9. 正则匹配 去掉 多余的js和html标签

    $reg17 = '/><strong>公司介绍<\/strong><\/td>([\S\s*]+?)<\/div>/'; $this->d ...

  10. php生成圆形图片

    http://files.cnblogs.com/files/adtuu/circle_image.zip