Least common multiple
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 38681 Accepted Submission (s): 21606
Problem Description
Given two positive integers, calculate the least common multiple of these two numbers.
Input
The input contains multiple sets of test data, with only one row per group, including two positive integers not greater than 1000.
Output
For each test case, the least common multiple of these two numbers is given, and each instance outputs a row.
Sample Input
10 14
Sample Output
70
Analysis: The method of dividing
#include <iostream> #include <stdio.h>using namespace std;int gcd (int a,int b) { if (b==0) return A; else return gcd (b,a%b);} int main () { int m,n,t; while (cin>>n>>m) { t=gcd (n,m); printf ("%d\n", (m*n)/t); } return 0;}
Hangzhou Electric---1108 least common multiple