#includeint lcm(int a,int b) { int s,g,l; g = a>b?a:b; l = a>b?b:a; s = g; while (1) { if (s%l==0) return s; s+=g; } } int main() { int a,b; while (scanf("%d%d",&a,&b)!=EOF) printf("%d\n",lcm(a,b)); }
本文共 258 字,大约阅读时间需要 1 分钟。
#includeint lcm(int a,int b) { int s,g,l; g = a>b?a:b; l = a>b?b:a; s = g; while (1) { if (s%l==0) return s; s+=g; } } int main() { int a,b; while (scanf("%d%d",&a,&b)!=EOF) printf("%d\n",lcm(a,b)); }
转载地址:http://lkmwa.baihongyu.com/