HUD 1019 Least common multiple

Source: Internet
Author: User
Tags gcd

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1019

Idea: The first two numbers first, then with the number of the request and the following one number, and so on

1#include <stdlib.h>2#include <time.h>3#include <cstdio>4#include <cstring>5#include <cmath>6#include <cstdlib>7#include <ctime>8#include <iostream>9#include <algorithm>Ten#include <vector> One#include <queue> A#include <map> -#include <Set> -#include <string.h> the using namespacestd; -  - intn,m; - intarr[ +]; +  - intgcdintAintb) + { A     if(b) at         returnGCD (b,a%b); -     Else -         returnA; - } -  - intLcmintAintb) in { -     returnA/GCD (A, b) *b;//A*B/GCD (A, b) data cannot be used here to overflow to } +  - intMain () the { *      while(SCANF ("%d", &n)! =EOF) $     {Panax Notoginseng          while(n--) -         { thescanf"%d",&m); +             intT; Ascanf"%d",&t); the              for(intI=1; i<=m-1; i++) +             { -scanf"%d",&arr[i]); $t=LCM (T,arr[i]); $             } -printf"%d\n", T); -              the         } -     } Wuyi     return 0; the}

HUD 1019 Least common multiple

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.