C/C++训练1---最大公约数与最小公倍数
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
输入两个正整数,求它们的最大公约数与最小公倍数。
Input
输入两个正整数,两个整数之间用空格分开。
数据保证在 int 范围内。
Output
第一行输出最大公约数;
第二行输出最小公倍数。
答案保证在 int 范围内。
Example Input
64 48
Example Output
16 192
Hint
Author
#include <stdio.h>
#include <stdlib.h>int main()
{int a,t,b,e,d;scanf("%d%d",&a,&b);d = a;e = b;if ( a < b){t = a;a = b;b = t;}while(b!=0){t = a % b;a = b;b = t;}printf("%d\n%d\n",a,(d*e)/a);return 0;
}