Guest User

ALEXTASK

a guest
Aug 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. long long lcm(long long x, long long y){
  4.     long long lc = 0;
  5.     while((lc++)+1){
  6.         if(x/y == 1){return x;}    
  7.         if(!((x*lc) % y)){return lc*x;}
  8.     }
  9. }
  10.  
  11. int main(){
  12.     int T;
  13.     scanf("%d", &T);
  14.     while(T--){
  15.         int n;
  16.         scanf("%d", &n);
  17.         long long lst = 0;
  18.         long long a[n];
  19.         for(int i=0; i<n; i++){
  20.             scanf("%lld", &a[i]);
  21.         }
  22.         for(int i=0; i<n; i++){
  23.             for(int j=i+1; j<n; j++){
  24.                 long long new = lcm(a[i],a[j]);
  25.                 lst = (!lst) ? new : ((new<lst) ? new : lst);
  26.             }
  27.         }
  28.         printf("%lld\n", lst);
  29.     }
  30.    
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment