Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/1243
- */
- #include <iostream>
- using namespace std;
- int n, res, l, a, tests;
- int gcd(int a, int b){
- return b == 0 ? a : gcd(b,a%b);
- }
- int lcm(int a, int b){
- return a/gcd(a,b)*b;
- }
- int main()
- {
- cin>>tests;
- while( tests-- ){
- cin>>n;
- res = 1;
- for(int i = 0; i < n; i++ ){
- cin>>a;
- res = lcm(res,a);
- }
- cout<<res<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment