1. 程式人生 > >hdu_1108 最小公倍數

hdu_1108 最小公倍數

style while 最小公倍數 == clu str c++ 定律 tro

//(a,b)最小公倍數=a*b/(a,b)最大公因數 
//最大公因數用歐幾裏得定律求(這裏不證明)可百度(說實話我好想不會orz)

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

hdu_1108 最小公倍數