unsigned long lcm(unsigned int a, unsigned int b)
{
unsigned int cd;
cd = gcd(a,b);
//cout << cd << endl;
return a*b/cd;
}
template<class T>
T gcd(T a, T b)
{
T fr, sr;
fr = max(a,b);
sr = min(a,b);
T r = 1;
while(r > 0){
r = fr%sr;
fr = sr;
sr = r;
}
return fr;
}
最小公倍数
最新推荐文章于 2019-07-22 10:18:57 发布