JAVA大数——lightoj1024

it2022-05-05  91

要用 System.gc() 清理内存

类必须命名成Main,一些大整数的操作

import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t,n; t=cin.nextInt(); BigInteger ans,m,d; for(int tt=1;tt<=t;tt++) { n=cin.nextInt(); m=cin.nextBigInteger(); ans=m; for(int i=1;i<n;i++) { m=cin.nextBigInteger(); d=ans.gcd(m); ans=ans.multiply(m).divide(d); } System.out.println("Case "+tt+": "+ans); System.gc(); } } }

 

转载于:https://www.cnblogs.com/zsben991126/p/11130457.html


最新回复(0)