# HDU acmsteps 2.1.1 least public multiple (GCD)

Source: Internet
Author: User
Minimum Public multiple

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)

Total submission (s): 2010 accepted submission (s): 1543

Problem description

Given two positive integers, calculate the minimum public multiples of these two numbers.

Input

The input contains multiple groups of test data. Each group has only one row, including two positive integers not greater than 1000.

Output

For each test case, the minimum public multiple of the two numbers is given, and each instance outputs a row.

Sample Input

` 10 14 `

Sample output

` 70 `

Source

Poj

Recommend

Eddy

` 1:# Include <iostream> `
`2:Using NamespaceSTD; `
` 3:IntGcd (IntA,IntB ){ `
` 4:Return(B = 0? A: gcd (B, A % B )); `
` 5:} `
` 6:IntMain (){ `
` 7:For(IntN, m; CIN> N> m ;){ `
` 8:Cout <n/gcd (n, m) * m <'\ N'; `
` 9:} `
`10:} `

Division of moving phase (also known as "EuclideanAlgorithm"):

Equality: gcd (a, B) = gcd (B, A % B );

Boundary Condition: gcd (A, 0) =;

The number of recursive layers of The GCD function cannot exceed 4.785lg (n) + 1.6723, where n = max {a, B };

It is worth mentioning that the maximum number of recursive layers of GCD is gcd (f (N), F (n-1), and F (n) is a series of Fibonacci;

(From Liu lujia's White Book, p117 );

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.