Advertisement
farsid

Untitled

Jul 27th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package farsid;
  6.  
  7. /**
  8. *
  9. * @author Farsid
  10. */
  11.  
  12. import java.util.Scanner;
  13. import java .math.BigInteger;
  14.  
  15. class Farsid {
  16.  
  17. /**
  18. * @param args the command line arguments
  19. */
  20.  
  21. public static void main(String[] args) {
  22. // TODO code application logic here
  23. Scanner scan= new Scanner(System.in);
  24. int T=scan.nextInt();int cas=1,a;
  25. for(cas=1;cas<=T;cas++)
  26. {
  27. int n=scan.nextInt();
  28. a=scan.nextInt();
  29. BigInteger lcm=BigInteger.valueOf(a);
  30. for(int i=1;i<n;i++)
  31. {
  32. a=scan.nextInt();
  33. BigInteger val=BigInteger.valueOf(a);
  34. //System.out.println(val);
  35. BigInteger gcd= lcm.gcd(val);
  36. //System.out.println(gcd);
  37. val=val.multiply(lcm);
  38. //System.out.println(val);
  39. lcm=val.divide(gcd);
  40. //System.out.println(lcm);
  41. }
  42. System.out.println("Case "+cas + ": "+lcm+ "\n");
  43. }
  44. // System.out.println();
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement