POJ 最小公倍数
#include <iostream> using namespace std; int main(){ int a,b,c,k; int tmp,ans; while(cin>>a>>b){ k=a*b; if(a<b){ tmp=a; a=b; b=tmp; } while(a%b!=0){ c=a%b; a=b; b=c; } ans=k/b; cout<<ans<<endl; } }
#include <iostream> using namespace std; int main(){ int a,b,c,k; int tmp,ans; while(cin>>a>>b){ k=a*b; if(a<b){ tmp=a; a=b; b=tmp; } while(a%b!=0){ c=a%b; a=b; b=c; } ans=k/b; cout<<ans<<endl; } }