LightOj 1024 EID


N:B :- Use Garbage Collector System.gc() after print to clear garbages and reduce memory size .




import java.math.*;
import java.util.Scanner;
import java.util.*;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        Scanner input =new Scanner(System.in);
        int i,j,t,tc;
        BigInteger [] a=new BigInteger[1005];
        BigInteger result,n;
        tc=input.nextInt();
        for(j=1;j<=tc;j++)
        {
            t=input.nextInt();
          
            for(i=0;i<t;i++)
            {
                n=input.nextBigInteger();
                a[i]=n;
            }
            result=a[0];
            for(i=1;i<t;i++)
            {
                result=result.multiply(a[i]).divide(result.gcd(a[i]));
            }
          
            System.out.println("Case "+j+": "+result);
            System.gc();
          }

        
    }
    
}

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment