/*
--------------------------------------------------------------------
stratege:素数筛选 + 整数拆分
一个整数x = p1^a1 + p2 ^ a2 + ... + pn ^ an
其中pi为素数。本题关键是找到存在pi^ai 中 ai的
最大值, 并将pi^ai的结果不断相乘,即为最小公倍数
Author : Johnsondu
2012-03-21 21:51:34 Accepted1007 0 MS976 KB GNU C++
---------------------------------------------------------------------
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
typedef __int64 LL ;
const int maxn = 78500 ;
int prime[7900] ;
int a[maxn], num ;
int mark[maxn] ;
LL res ;
void init ()
{
int i, j, k ;
memset (a, 0, sizeof(a)) ;
num = 1 ;
prime[0] = 2 ;
for (i = 4; i < maxn; i += 2)
a[i] = 1 ;
for (i = 3; i < maxn; i += 2)
{
if (!a[i])
{
prime[num++] = i ;
int tmp = 2 * i ;
while (tmp < maxn)
{
a[tmp] = 1 ;
tmp += i ;
}
}
}
}
int max (int a, int b)
{
return a > b ? a : b ;
}
int main()
{
int i, j, k, tmp ;
unsigned int tcase, n, cnt ;
LL res, ans ;
init () ;
memset (mark, 0, sizeof(mark)) ;
cin >> tcase ;
while (tcase --)
{
cin >> n ;
res = 1 ;
ans = 1 ;
for (i = 0; i < n; i ++)
{
cin >> cnt ;
for (j = 0; j < num; j ++)
{
if (cnt < prime[j])
break ;
tmp = 0 ;
if (cnt % prime[j] == 0)
{
tmp ++ ;
cnt /= prime[j] ;
while (cnt % prime[j] == 0)
{
tmp ++ ;
cnt /= prime[j] ;
}
mark[prime[j]] = max (tmp, mark[prime[j]]) ;
}
}
if (cnt != 1)
ans = cnt ;
}
for (i = 0; i < num; i ++)
if (mark[prime[i]])
{
while (mark[prime[i]] --)
res *= prime[i] ;
}
res *= ans ;
cout << res << endl ;
memset(mark, 0, sizeof(mark)) ;
}
return 0 ;
}相关推荐
全志Longan和Tina系统T113-S3-(Tina Linux 系统介绍)
Tina Linux是全志科技基于Linux内核开发的针对智能硬件类产品的嵌入式软件系统。Tina Linux基于openwrt-14.07 版本的软件开发包,包含了 Linux 系统开发用到的内核源码、驱动、工具、系统中间件与应用程序包。Tina系统软件架构如图所示。从下至上分别为Kernel && Driver、Libraries、System Services、Applications 四层。
1019 Least Common Multiple
#include #include using namespace std; int main() { int flag; long n,m,val; vector v; while (cin >> n) { while (n--&&cin >> m) { while (m--&&cin >> val) v.push_back(val); for (int
ESP-01S使用micropython,利用Thonny烧写固件
在家舒服的太久了,想学习点新的东西,这次看上了ESP8266系列的联网设备,想自己做点小玩意出来耍耍,下面跟我一起来学习吧。本篇主要记录固件的烧写及测试。Thonny下载链接不算难,但是网上资源较少。也是提醒自己不要忘记这个步骤,记录一下,也分享给和我一样开始接触的小伙伴,加油加油,万事开头难。
hdu 1019 Least Common Multiple
Least Common Multiple Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 62729 Accepted Submission(s): 23974 Problem Description The least...
Amesim与Simulink联合仿真:S-Function接口配置与实战避坑指南
本文详细介绍了Amesim与Simulink联合仿真中S-Function接口的配置方法与实战避坑指南。从环境搭建、编译器配置到S-Function接口实战,逐步解析关键步骤与常见问题解决方案,帮助工程师高效实现多领域系统仿真,特别适合汽车、航空航天等复杂系统建模场景。
银河麒麟系统完美安装EasyConnect
Kylin V10桌面版完美安装EasyConnect
toj 1528 Least Common Multiple
Least Common Multiple Time Limit: 1.0 Seconds Memory Limit: 65536K Total Runs: 3659 Accepted Runs: 1542The least common multiple (LCM) of a set of positive integers is the smallest positive inte
uniapp [全端兼容] - 实现内网使用天地图离线地图,详解项目加载天地图的离线地图服务器部署与使用教程示例源码,Uniapp如何实现天地图的离线加载部署在内网访问(兼容H5、微信小程序、App)
uniapp天地图如何离线访问,无需网络调用天地图API,天地图离线地图,天地图——内网使用离线地图,uniapp中加载天地图的离线地图,uniAPP实现天地图离线访问,在内网中无法直接使用外网天地图资源怎么办,在uni-app中加载地图 -使用天地图的瓦片数据。UNIAPP天地图离线怎么使用,内网部署天地图,天地图离线瓦片,部分瓦片数据,天地图如何离线,下载天地图离线服务,并用Uniapp+天地图离线部署,天地图私有化部署,实现离线加载天地图,Java+uniapp天地图离线开发,uniapp项目中无网络
ACM--最大公约数--HDOJ 1019--Least Common Multiple--水
HDOJ题目地址:传送门 Least Common Multiple Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 45286 Accepted Submission(s): 17030
i.MX6ULL系统移植 | 使用busybox制作根文件系统(1.29.0)
一. 下载BusyBox BusyBox是一个继承了大量Linux命令核工具的软件,像常用的ls、cp、mv、ifconfig等命令。一般下载BusyBox的源码,然后配置Busybox,选择自己想要的功能,最后编译即可。 BusyBox在官方可以直接下载:https://www.busybox.net/。目前最新是1.35.0,这里我使用1.29.0版本。 axel https://www.busybox.net/downloads/busybox-1.29.0.tar.bz2 下载之后解压: tar
GB28181 —— 3、C++编写GB28181设备端,完成注册、注销、保活心跳、响应查询目录等功能(附源码)
GB28181 —— Win10下编写GB28181设备端,完成注册、注销、保活心跳、响应查询目录等功能(附源码)
ACM-简单题之Least Common Multiple——hdu1019
ACM 简单题 Least Common Multiple hdu1019 最小公倍数
TC3XX - MCAL知识点(三十五):Tasking编译器下,Tc3xx的MCAL代码如何使用多核,多核中断、多核任务、多核外设之间的MCAL配置与代码例程
文章用于记录在裸机情况下使用多核Tc387芯片,如何高效运行以及正确的代码、工程属性、链接文件配置等问题,相互结合、相互影响的地方,以示后续使用记录。
HDU1019 Least Common Multiple
HDU 1019Least Common Multiple Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 68851 Accepted Submission(s): 26323 Problem Descrip...
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
HDU-1019 Least Common Multiple
HDU 1019 Least Common Multiple The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 ...
win10 跳过U8环境检测的IE WebControls.rar
win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。
ACM hdu 1019 Least Common Multiple
ACM hdu 1019 Least Common Multiple Problem Description The least common multiple (LCM) of a set of positive integers is t...
锂电池充电器电路设计 里面有电路
锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。
hdu 1019 Least Common Multiple
hdu 1019 Least Common Multiple 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1019 数学水 题目大意:求一串数的最小公倍数。 题目分析:每输入一个数,求一下中间结果。 code: #include int gcd(int a,int b) { while(b^=a^=b^=a%
算法模板之欧几里得算法(HDU1019 Least Common Multiple)
模板总结归纳://欧几里得算法(辗转相除法) //O(logN) /*int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } */实战模板题 :HDU1019 Least Common Multiple#include<iostream> #include<cstdio> using namespa...
HDU ACM1019——Least Common Multiple
Least Common Multiple Problem Description The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For examp...
hdu1019 Least Common Multiple
Least Common Multiple Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 28021Accepted ...
6331



被折叠的 条评论
为什么被折叠?



