Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package farsid;
- /**
- *
- * @author Farsid
- */
- import java.util.Scanner;
- import java .math.BigInteger;
- class Farsid {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner scan= new Scanner(System.in);
- int T=scan.nextInt();int cas=1,a;
- for(cas=1;cas<=T;cas++)
- {
- int n=scan.nextInt();
- a=scan.nextInt();
- BigInteger lcm=BigInteger.valueOf(a);
- for(int i=1;i<n;i++)
- {
- a=scan.nextInt();
- BigInteger val=BigInteger.valueOf(a);
- //System.out.println(val);
- BigInteger gcd= lcm.gcd(val);
- //System.out.println(gcd);
- val=val.multiply(lcm);
- //System.out.println(val);
- lcm=val.divide(gcd);
- //System.out.println(lcm);
- }
- System.out.println("Case "+cas + ": "+lcm+ "\n");
- }
- // System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement