hdu 2028 Lowest Common Multiple Plus(最小公倍数)
Lowest Common Multiple Plus
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 34980 Accepted Submission(s): 14272
#include<iostream>
#include<stdio.h>
using namespace std;
typedef __int64 inta;
inta gcd(inta a,inta b)
{
if(b==)
return a;
return gcd(b,a%b);
}
inta lcm(inta a,inta b)
{
return a*b/gcd(a,b);
}
int main()
{
int n;
while(cin >> n)
{
__int64 a;
__int64 vis=;
while(n--)
{
scanf("%I64d",&a);
vis = lcm(vis,a);
}
printf("%I64d\n",vis);
}
return ;
}
hdu 2028 Lowest Common Multiple Plus(最小公倍数)的更多相关文章
- HDU 2028 Lowest Common Multiple Plus
http://acm.hdu.edu.cn/showproblem.php?pid=2028 Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个 ...
- #2028 Lowest Common Multiple Plus
http://acm.hdu.edu.cn/showproblem.php?pid=2028 应该是比较简单的一道题啊...求输入的数的最小公倍数. 先用百度来的(老师教的已经不知道跑哪去了)辗转相除 ...
- 杭电 2028 ( Lowest Common Multiple Plus )
链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2028 题目要求:就是求最大公倍数,我百度了一下,最好实现的算法就是: 公式法 由于 ...
- 最大公约数最小公倍数 (例:HDU2028 Lowest Common Multiple Plus)
也称欧几里得算法 原理: gcd(a,b)=gcd(b,a mod b) 边界条件为 gcd(a,0)=a; 其中mod 为求余 故辗转相除法可简单的表示为: int gcd(int a, int b ...
- Lowest Common Multiple Plus
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 背包系列练习及总结(hud 2602 && hdu 2844 Coins && hdu 2159 && poj 1170 Shopping Offers && hdu 3092 Least common multiple && poj 1015 Jury Compromise)
作为一个oier,以及大学acm党背包是必不可少的一部分.好久没做背包类动规了.久违地练习下-.- dd__engi的背包九讲:http://love-oriented.com/pack/ 鸣谢htt ...
- HDU - 1019-Least Common Multiple(求最小公倍数(gcd))
The least common multiple (LCM) of a set of positive integers is the smallest positive integer which ...
- HDU 1019 Least Common Multiple【gcd+lcm+水+多个数的lcm】
Least Common Multiple Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- HDU 4913 Least common multiple
题目:Least common multiple 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4913 题意:有一个集合s,包含x1,x2,...,xn, ...
随机推荐
- c# 远程回收IIS应用池
利用下列代码可实现IIS应用池的远程回收 var serverManager = ServerManager.OpenRemote(ip); var appPools = serverManager. ...
- 【译】 Node.js v0.12的新特性 -- Cluster模式采用Round-Robin负载均衡
原文:https://strongloop.com/strongblog/whats-new-in-node-js-v0-12-cluster-round-robin-load-balancing 本 ...
- java filter的一些理解
java filter即 java中的过滤器: 一. * web项目中只有三个组件 * 过滤器filter ↓ 级 别 * 监听器 ↓ 级 别 * servlet ...
- UVaLive 3708
题意:周长为10000的圆上等距分布n个雕塑,求再加入m个雕塑后,为使所有雕塑等距分布所需移动原来n个雕塑的最小总距离. 分析:计算相对距离. #include<cstdio> #incl ...
- STL merge的实现细节
//std::merge的两个版本 template<class InputIt1, class InputIt2, class OutputIt> //First version Out ...
- 【原】Oracle拼接字段
select FLIGHT_DATE, replace(wm_concat(FLIGHT_NO), ',', '*') FLIGHT_NO from T2001 group by FLIGHT_DAT ...
- LeetCode 解题报告--202Happy Number
1 题目描述 Write an algorithm to determine if a number is "happy". A happy number is a number ...
- lazy instructor
Description A math instructor is too lazy to grade a question in the exam papers in which students a ...
- Mysql 如何删除数据表中的重复数据!
1.使用distinct查询所有不重复的记录 2.创建数据表相同结构的临时表,将第一步的数据复制进去 create temporary table if not exists student_temp ...
- "!x++" 我之见解
"!x++"之说,各人见解不同,但真理只有一个.我只尝试着说出一种见解,未知真相. 何如? "!x++"等价于"!(x++)". 理论分析 ...