Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- long long lcm(long long x, long long y){
- long long lc = 0;
- while((lc++)+1){
- if(x/y == 1){return x;}
- if(!((x*lc) % y)){return lc*x;}
- }
- }
- int main(){
- int T;
- scanf("%d", &T);
- while(T--){
- int n;
- scanf("%d", &n);
- long long lst = 0;
- long long a[n];
- for(int i=0; i<n; i++){
- scanf("%lld", &a[i]);
- }
- for(int i=0; i<n; i++){
- for(int j=i+1; j<n; j++){
- long long new = lcm(a[i],a[j]);
- lst = (!lst) ? new : ((new<lst) ? new : lst);
- }
- }
- printf("%lld\n", lst);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment