Minimum Public multiple of HDU 1108

Source: Internet
Author: User

When the onset of laziness cancer occurs, you need to exercise questions.


GCD + LCM calculate GCD and then LCM.

 
Int gcd (int A, int B) {int r = 0; while (B! = 0) {r = A % B; A = B; B = r;} return ;}

Example 10 14

10% 14 = 10; A = 14, r = 10, B = 10;

14% 10 = 4, A = 10, r = 4, B = 4;

10% 4 = 2, A = 4, r = 2, B = 2;

4% 2 = 0, A = 2, r = 0, B = 0;

Therefore, gcd = 2;


# Include <cstdio> # include <cstring> # include <string> # include <queue> # include <algorithm> # include <map> # include <stack> # include <iostream> # include <list> # include <set> # include <cmath> # define INF 0x7fffffff # define EPS 1e-6 # define ll long # define clri for (INT I = 0; I <n; I ++) # define clrj for (Int J = 0; j <n; j ++) # define clrk for (int K = 0; k <N; k ++) # define debug puts ("= Fuck ="); # define acfun STD: IOS: sync_with_stdio (Fa LSE) # define Nmax 1001 # define mMax 1001*1001 using namespace STD; int gcd (int A, int B) {int r = 0; while (B! = 0) {r = A % B; A = B; B = r;} return a;} int lcm (int A, int B, int g) {return a * B/g;} int main () {int A, B; while (~ Scanf ("% d", & A, & B) {printf ("% d \ n", lcm (a, B, gcd (, b);} return 0 ;}




Minimum Public multiple of HDU 1108

Contact Us

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.