标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 46786 Accepted Submission(s): 17601
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int gcd(int n, int m){ //大小交换 if(m>n){ int temp = n; n =m; m = temp; } int r =1; while(m!=0){ r = n%m; n = m; m = r; } return n; } int main() { int t, x; cin>>t; while(t--){ int n,b, sum=1; cin>>n; for(int i=0; i<n; i++){ cin>>x; b = gcd(sum, x); sum = sum/b*x; } printf("%d\n",sum); } return 0; }
HDU 1019 Least Common Multiple
标签:
原文地址:http://www.cnblogs.com/lzeffort/p/5906862.html