【ACM】最小公倍数
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2§ionid=1&problemid=1
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int a,b,c,m,n; while( scanf( "%d%d" , &n , &m ) != EOF ) { if( n > m) { a = n ; b = m ; } else { a = m ; b = n; } while ( b != 0 ) { /* 最小公倍数 = m*n/GCD(m,n) */ c = a % b ; a = b ; b = c ; } printf( "%d\n" , ( m * n ) /a ); } return 0; }