View Code of Problem 59

#include<stdio.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int c,d;
	c=a;d=b;
	int i,t;
	int gcd,max;
	if(b>a){
		t=a;
		a=b;
		b=t;
	}
//	for(i=1;i<=a;i++){
//		if(a%i==0&&b%i==0){
//			gcd=i;
//		}
//	}
	//使用辗转相除法
	while(b!=0){
		t=a%b;
		a=b;
		b=t;
	} 
	gcd=a;
	 max=d*c/gcd;
	printf("%d %d",max,gcd);
	return 0;
}

Double click to view unformatted code.


Back to problem 59