Lightoj 1024 - Eid
求n个数的最小公倍数。
import java.math.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class Main{ /**
* @param args
*/
public static BigInteger lcm(BigInteger a,BigInteger b){
return a.divide(a.gcd(b)).multiply(b);//.divide(a.gcd(b));
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin=new Scanner(System.in);
int T,n;
T=cin.nextInt();
for(int t=1;t<=T;t++){
n=cin.nextInt();
BigInteger x=new BigInteger("1");
BigInteger ans=new BigInteger("1");
for(int i=1;i<=n;i++){
x=cin.nextBigInteger();
ans=lcm(ans,x);
}
System.out.println("Case "+t+": "+ans);
System.gc();
}
} }
得用
System.gc();
手动释放内存...
Lightoj 1024 - Eid的更多相关文章
- LightOj 1024 - Eid (求n个数的最小公约数+高精度)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1024 题意:给你n(2<=n<=1000)个数, 然后求n个数的最小公倍数 ...
- LightOJ 1024 Eid(高精度乘法+求n个数最小公约数)
题目链接:https://vjudge.net/contest/28079#problem/T 题目大意:给你n个数求这些数的最小公倍数(约数). 解题思路:还太菜了,看了别人的题解才会写,转自这里, ...
- lightoj 1024 (高精度乘单精度)
题意:给你一些数,求它们的最小公倍数,结果可能会很大. 统计出每个素因子出现的最大次数,把他们相乘即可,需要高精度. #include<cmath> #include<cstdio& ...
- (light oj 1024) Eid (最小公倍数)
题目链接: http://lightoj.com/volume_showproblem.php?problem=1024 In a strange planet there are n races. ...
- python3爬取1024图片
这两年python特别火,火到博客园现在也是隔三差五的出现一些python的文章.各种开源软件.各种爬虫算法纷纷开路,作为互联网行业的IT狗自然看的我也是心痒痒,于是趁着这个雾霾横行的周末瞅了两眼,作 ...
- mysql Packet for query is too large (1185 > 1024)异常
注:最近mysql一直提示如下错误 Packet for query is too large (1185 > 1024). You can change this value on the s ...
- 区间DP LightOJ 1422 Halloween Costumes
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...
- LightOj 1298 - One Theorem, One Year(DP + 欧拉)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...
- 1214 - Large Division -- LightOj(大数取余)
http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...
随机推荐
- Java 常用集合笔记
自增数组 ArrayList<Integer>G[]=new ArrayList[N] 详细笔记 相关题目 栈 Stack<Integer> stack=new Stack&l ...
- HDU 1257 最少拦截系统(最长上升子序列)
题意: 给定n个数, 然后要求看看有多少对不上升子序列. 分析: 求出最长上升子序列, 那么整个序列中LIS外的数都会在前面找到一个比自己大的数, 所以不上升子序列最多有最长上升子序列个数个. 关于求 ...
- 【01】sass基础信息:
[01]基础信息: 2016年4月16日 最新版本:3.4.22 官网:http://sass-lang.com/(下图) CSStoSCSS 网站:http://css2sa ...
- AutoItLibrary之键盘操作(send)
最近有人问到我键盘操作用什么库?用到库里面的哪个方法?我在这里总结一下,第一次写,有片面的地方还请指出,一块进步.1.首先,用到的库是AutoItLibrary,用到的方法是send:按F5可用看到 ...
- @locked_cached_property ---flask.helpers模块
源码: class locked_cached_property(object): """A decorator that converts a function int ...
- Laya 类列表加载优化
Laya 类列表加载优化 @author ixenos 类列表:在一个页面展示的大量的零散单元的集合(聊天面板.背包) 一.按展示优化1.展示内容少,即使大量数据,但用户只看到少量信息的时候,考虑按需 ...
- 1027 stl
#include<stdio.h> #include<queue> using namespace std; int main() { int i,n,m,j,k,a[100 ...
- 子串(codevs 4560)
题目描述 Description 有两个仅包含小写英文字母的字符串A和B.现在要从字符串A中取出k个互不重叠的非空子串,然后把这k个子串按照其在字符串A中出现的顺序依次连接起来得到一个新的字符串,请问 ...
- SpringBoot自动配置的源码解析
首先,写源码分析真的很花时间,所以希望大家转的时候也请注明一下,Thanks♪(・ω・)ノ SpringBoot最大的好处就是对于很多框架都默认的配置,让我们开发的时候不必为了大一堆的配置文件头疼,关 ...
- DatePickerDialog
package com.pingyijinren.helloworld.activity; import android.app.DatePickerDialog; import android.su ...