天天看點

D - 最小公倍數

D - 最小公倍數 

HPU專題訓練(-1)GCD&&素篩&&快速幂_____D - 最小公倍數

給定兩個正整數,計算這兩個數的最小公倍數。

Input輸入包含多組測試資料,每組隻有一行,包括兩個不大于1000的正整數.Output對于每個測試用例,給出這兩個數的最小公倍數,每個執行個體輸出一行。 Sample Input

10 14

Sample Output

/*
  就是找gcd(a,b)
  ans=a*b/gcd(a,b) 
*/

#include<stdio.h> 
int p(int a,int b)
{
  return !b?a:p(b,a%b); 
}
int main()
{
  int x,y;
  while(scanf("%d %d",&x,&y)!=EOF)
  {
    printf("%d\n",x*y/p(x,y));
  }
  return 0;
}