杭电1019Least Common Multiple
作者:互联网
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1019
解题思路:
Talk is cheap. Show me the code.
没有技巧全是感情
1 #include<bits/stdc++.h>//hduoj1019lcm 2 using namespace std; 3 int a[1010]; 4 int lcm(int a,int b) 5 { 6 return a/__gcd(a,b)*b; 7 } 8 int main() 9 { 10 std::ios::sync_with_stdio(false); 11 int t; 12 cin>>t; 13 while(t--) 14 { 15 int n; 16 cin>>n; 17 for(register int i=1;i<=n;i++) 18 cin>>a[i]; 19 int ans=a[1]; 20 for(register int i=2;i<=n;i++) 21 ans=lcm(ans,a[i]); 22 cout<<ans<<endl; 23 } 24 return 0; 25 }
标签:std,__,code,Multiple,1019Least,int,register,cin,杭电 来源: https://www.cnblogs.com/LQS-blog/p/16221127.html