Problem Description


求n个数的最小公倍数。

Input


输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。

Output


为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。

Sample Input

2 4 6
3 2 5 7

Sample Output

12
70
#include <bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define PI acos(-1)
#define bug puts("here")
#define REP(i,x,n) for(int i=x;i<=n;i++)
#define DEP(i,n,x) for(int i=n;i>=x;i--)
#define mem(a,x) memset(a,x,sizeof(a))
typedef unsigned long long ull;
using namespace std;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
inline void Out(int a){if(a<0) putchar('-'),a=-a;if(a>=10) Out(a/10);putchar(a%10+'0');
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){int n;while(cin>>n){ll tmp=read(),x,y=tmp;REP(i,2,n){x=read();y=y/gcd(tmp,x)*x;tmp=y;}printf("%lld\n",tmp);}return 0;
}

转载于:https://www.cnblogs.com/zsyacm666666/p/7627034.html

【HDU 2028】Lowest Common Multiple Plus相关推荐

  1. HDU2028 Lowest Common Multiple Plus【GCD+LCM】

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...

  2. HDU2028 Lowest Common Multiple Plus【入门】

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  3. 大数加法【HDU 1002】

    大数加法模板 一般的加法只要int类型的两数直接相加即可,大一点的数可以设为long long类型,而超过长整型的数则属于大数问题了,大数加法其实也比较简单,利用数组实现就可以啦: 主要思想如下: ( ...

  4. Lowest Common Multiple Plus ——ACM

    1. Lowest Common Multiple Plus 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.为每组测试数据输出它们的最小 ...

  5. 【 HDU - 5093】Battle ships(匈牙利算法,二分图匹配)

    题干: Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission ...

  6. 【HDU - 1455】Sticks (dfs + 剪枝)

    题干: George took sticks of the same length and cut them randomly until all parts became at most 50 un ...

  7. 【HDU - 4006】The kth great number (优先队列,求第k大的数)

    题干: Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to wri ...

  8. 【HDU - 4217 】Data Structure? (线段树求第k小数)

    题干: Data structure is one of the basic skills for Computer Science students, which is a particular w ...

  9. 【HDU - 1754】I Hate It (线段树模板 单点覆盖更新+区间最大值查询)

    题干: 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.  这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当 ...

最新文章

  1. 牛客华为机试第8题python
  2. 查看HTML代码却被当黑客,记者好心报告漏洞,反遭美国州长起诉
  3. 【金三银四】java是世界上最好的语言
  4. 开发日记-20190519 关键词 Linux学习路径
  5. 如何学习开源系统有感(一)
  6. HTTP协议那些不得不说的事
  7. PHP MYSQL关键词统计系统_PHP MySQL Order By 关键词
  8. springcloud maven打包部署
  9. adobe reader运行时出现“Invalid plugin detected”错误的解决办法
  10. 职称计算机怎么练,2017职称计算机windows操作训练题
  11. ConcurrentLinkedQueue 的outofMemory错误解决方案
  12. SQL WITH AS
  13. C语言小游戏,游戏设计,500+行代码
  14. win10没有realtek高清晰音频管理器_【微软】第49期分享:装完Win 10最新补丁数据没了!...
  15. MySQL数据库 实验报告(三)
  16. VBA让Excel数据去重,数量相加
  17. 由于找不到 MSVCR120.dll,无法继续执行代码解决方法
  18. 又一个好用的xbox360手柄驱动
  19. CVTE面试总结(全网面经,已收offer)
  20. ubuntu下文本标注工具BRAT全程离线安装

热门文章

  1. 移动开发必须要了解的易盾加固生态
  2. Elasticsearch使用
  3. jQuery操作input
  4. 活动目录最佳实践分析器
  5. idea搭建javaweb项目 Artifacts生成
  6. 第6章 数组----复制数组
  7. grub resourceunknown filesystem异常处理
  8. 127 - Accordian Patience
  9. 《Sibelius 脚本程序设计》连载(二十六) - 2.13 utils库中的函数
  10. 数据结构 — 哈希表