HDOJ1108【最小公倍数。。】

it2022-05-17  66

#include <stdio.h>int 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));}

 

转载于:https://www.cnblogs.com/CheeseZH/archive/2012/03/31/2426982.html

相关资源:数据结构—成绩单生成器

最新回复(0)