#include <stdio.h> #define type_t long long type_t gcb(type_t a, type_t b); type_t lcm(type_t a, type_t b); void swap1(type_t *, type_t *); int main() { type_t a, b; while(scanf("%lld%lld",&a , &b) == 2) { printf("%lld\n",lcm(a, b)); } return 0; } type_t gcb(type_t a, type_t b) { while(a % b) { a = a % b; swap1(&a, &b); } return b; } type_t lcm(type_t a, type_t b) { return a*b/gcb(a,b); } void swap1(type_t * a, type_t * b) { int temp = *a; * a = * b; *b = temp; }
注意数可能越界,用long long, 其实用unsiged long 就可以了