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