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

Problem Description
求n个数的最小公倍数。
 
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。
 
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。
 
Sample Input
2 4 6
3 2 5 7
 
Sample Output
12
70
 
Author
lcy
 
Source
 
PS:欧几里得算法gcd
 
 
 #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(最小公倍数)的更多相关文章

  1. HDU 2028 Lowest Common Multiple Plus

    http://acm.hdu.edu.cn/showproblem.php?pid=2028 Problem Description 求n个数的最小公倍数.   Input 输入包含多个测试实例,每个 ...

  2. #2028 Lowest Common Multiple Plus

    http://acm.hdu.edu.cn/showproblem.php?pid=2028 应该是比较简单的一道题啊...求输入的数的最小公倍数. 先用百度来的(老师教的已经不知道跑哪去了)辗转相除 ...

  3. 杭电 2028 ( Lowest Common Multiple Plus )

    链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2028 题目要求:就是求最大公倍数,我百度了一下,最好实现的算法就是:       公式法 由于 ...

  4. 最大公约数最小公倍数 (例:HDU2028 Lowest Common Multiple Plus)

    也称欧几里得算法 原理: gcd(a,b)=gcd(b,a mod b) 边界条件为 gcd(a,0)=a; 其中mod 为求余 故辗转相除法可简单的表示为: int gcd(int a, int b ...

  5. Lowest Common Multiple Plus

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

  6. 背包系列练习及总结(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 ...

  7. HDU - 1019-Least Common Multiple(求最小公倍数(gcd))

    The least common multiple (LCM) of a set of positive integers is the smallest positive integer which ...

  8. 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 ...

  9. HDU 4913 Least common multiple

    题目:Least common multiple 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4913 题意:有一个集合s,包含x1,x2,...,xn, ...

随机推荐

  1. popViewControllerAnimated 后,对页面内UITableView 内数据刷新

    popViewControllerAnimated后,这时它不执行viewDidLoad,所以不能及时对viewControler及时刷新,此时对该页面进行操作可以调用viewWillAppear:( ...

  2. Android 应用程序的组成部分

    Android应用程序由松散耦合的组件组成,并使用应用程序Manifest绑定到一起,应用程序Manifest描述了每一个组件和它们之间的交互方式,还用于制定应用程序元数据.其硬件和平台要求.外部库以 ...

  3. windows API 核心编程学习心得

    一.错误处理 在内部,当windows函数检测到错误时,它会使用“线程本地存储区”的机制将相应的错误代码与“主调线程”关联到一起. winError.h 一般在C:\Program Files\Mic ...

  4. 一个疑惑的的问题-ntvdm.exe进程

    今天测试反馈了一个问题,在启动我们程序某个模块的程序时,会立即出现一个ntvdm.exe进程,此进程会占用大量的系统资源,导致系统卡住. 当第一眼看到这个现象时,以为是电脑中毒了,所以立即在网上查. ...

  5. bzoj 1040 骑士

    这题真不爽,各种WA,写个题解浏览器还挂了,真不爽. 所以不多说了,就说关于判断是否是父节点的问题,不能直接判,会有重边,这种情况只能用编号判,传进去入边的编号,(k^1) != fa,这样就可以了. ...

  6. debian 学习记录-1 -安装

    之前装ubuntu12. 后来没有继续用,图形界面很不错,没有继续学习原因很多: · 没有基础知识支持(拷贝文件都是用鼠标拖动的) · 图形界面很好,导致没有使用命令行,安装驱动什么的都是靠鼠标点击 ...

  7. Angularjs在线编辑器

    1.TextAngular: https://github.com/fraywing/textAngular textAngular是一个强大的Text-Editor/Wysiwyg 编辑器,用于An ...

  8. NHibernate各种查询

    NHibernate各种查询 NHibernate's methods of querying are powerful, but there's a learning curve. Longer t ...

  9. DTCMS中部分IE8不支持webupload上传附件的控件,更改为ajaxfileupload

    dialog\dialog_attach.aspx <!DOCTYPE html> <html> <head> <meta http-equiv=" ...

  10. 一款jquery写出来的tab切换

    当时做这个的时候,当前状态是不规则的,li对应的有3块内容,分别设定不同背景图片,只显示当前的一个背景,鼠标移上去的时候其余2个用background-position: -1000px 0px;来隐 ...