-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALEXTASK.cpp
58 lines (51 loc) · 937 Bytes
/
ALEXTASK.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Question: https://www.codechef.com/NOV16/problems/ALEXTASK
Status: Wrong Answer
*/
#include <bits/stdc++.h>
#define lli long long int
#define li long int
using namespace std;
lli gcd(lli a, lli b)
{
lli min=(a>b)?b:a;
for(int i=min; i>=2; i--)
{
if(a%i==0 && b%i==0)
{
return i;
break;
}
}
}
lli lcm(lli a, lli b)
{
lli leastcm;
leastcm=(a*b)/gcd(a,b);
return leastcm;
}
int main()
{
li t;
cin>>t;
while(t--)
{
int n;
cin>>n;
lli a[510]={0},min=500;
for(int i=1; i<=n; i++)
cin>>a[i];
for(int i=1; i<=n-1; i++)
{
for(int j=i+1; j<=n; j++)
{
if(min>lcm(a[i],a[j]))
{
min=lcm(a[i],a[j]);
}
}
}
cout<<min<<endl;
}
return 0;
}