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();
}
}
}
0 comments:
Post a Comment