【HDU 2028】Lowest Common Multiple Plus
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相关推荐
- HDU2028 Lowest Common Multiple Plus【GCD+LCM】
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- HDU2028 Lowest Common Multiple Plus【入门】
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- 大数加法【HDU 1002】
大数加法模板 一般的加法只要int类型的两数直接相加即可,大一点的数可以设为long long类型,而超过长整型的数则属于大数问题了,大数加法其实也比较简单,利用数组实现就可以啦: 主要思想如下: ( ...
- Lowest Common Multiple Plus ——ACM
1. Lowest Common Multiple Plus 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.为每组测试数据输出它们的最小 ...
- 【 HDU - 5093】Battle ships(匈牙利算法,二分图匹配)
题干: Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission ...
- 【HDU - 1455】Sticks (dfs + 剪枝)
题干: George took sticks of the same length and cut them randomly until all parts became at most 50 un ...
- 【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 ...
- 【HDU - 4217 】Data Structure? (线段树求第k小数)
题干: Data structure is one of the basic skills for Computer Science students, which is a particular w ...
- 【HDU - 1754】I Hate It (线段树模板 单点覆盖更新+区间最大值查询)
题干: 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当 ...
最新文章
- 牛客华为机试第8题python
- 查看HTML代码却被当黑客,记者好心报告漏洞,反遭美国州长起诉
- 【金三银四】java是世界上最好的语言
- 开发日记-20190519 关键词 Linux学习路径
- 如何学习开源系统有感(一)
- HTTP协议那些不得不说的事
- PHP MYSQL关键词统计系统_PHP MySQL Order By 关键词
- springcloud maven打包部署
- adobe reader运行时出现“Invalid plugin detected”错误的解决办法
- 职称计算机怎么练,2017职称计算机windows操作训练题
- ConcurrentLinkedQueue 的outofMemory错误解决方案
- SQL WITH AS
- C语言小游戏,游戏设计,500+行代码
- win10没有realtek高清晰音频管理器_【微软】第49期分享:装完Win 10最新补丁数据没了!...
- MySQL数据库 实验报告(三)
- VBA让Excel数据去重,数量相加
- 由于找不到 MSVCR120.dll,无法继续执行代码解决方法
- 又一个好用的xbox360手柄驱动
- CVTE面试总结(全网面经,已收offer)
- ubuntu下文本标注工具BRAT全程离线安装