HDOJ2028Lowest Common Multiple Plus
Lowest Common Multiple Plus
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 30907 Accepted Submission(s): 12528
3 2 5 7
70
解题报告:
先置n个元素最小公倍数为k = 1,然后依次将n个元素与k求最小公倍数,两个两个求。每个将两个元素的最小公倍数与下一个元素继续求最小公倍数。
详细情况见代码。
#include<stdio.h> int func(int m, int n)
{
int i;
if(m > n)
{
int t = m;
m = n;
n = t;
}
for(i = n; ; i++)
{
if(i%m == && i%n==)
break;
}
return i;
}
int main()
{
int n, m;
while(scanf("%d", &n) == )
{
int i, k = ;
for(i = ; i < n; i++)
{
scanf("%d", &m);
k = func(m, k);
}
printf("%d\n", k);
}
return ;
}
HDOJ2028Lowest Common Multiple Plus的更多相关文章
- hdoj-2028-Lowest common multiple plus
题目:Lowest common multiple plus 代码: #include<stdio.h> int common(int a,int b)//计算最大公约数 { int c= ...
- K - Least Common Multiple
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Descr ...
- [UCSD白板题] Least Common Multiple
Problem Introduction The least common multiple of two positive integers \(a\) and \(b\) is the least ...
- hdu1019 Least Common Multiple
Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...
- hdu 2028 Lowest Common Multiple Plus(最小公倍数)
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- 九度OJ 1056--最大公约数 1439--Least Common Multiple 【辗转相除法】
题目地址:http://ac.jobdu.com/problem.php?pid=1056 题目描述: 输入两个正整数,求其最大公约数. 输入: 测试数据有多组,每组输入两个正整数. 输出: 对于每组 ...
- HDU-1019 Least Common Multiple
http://acm.hdu.edu.cn/showproblem.php?pid=1019 Least Common Multiple Time Limit: 2000/1000 MS (Java/ ...
- Least Common Multiple
地址:http://www.codewars.com/kata/5259acb16021e9d8a60010af/train/python 题目: Write a function that calc ...
- ACM hdu 1019 Least Common Multiple
Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...
随机推荐
- Unity3D之飞机游戏追踪导弹制作
最近开发完成一款打飞机的游戏,记录一下制作追踪导弹的方法,最开始在网上找到的资料制作出来的追踪导弹都不够真实,主要的问题是没有对导弹进行一个阀值处理,导弹每帧都始终会面向目标,而不是按照一定的角度进行 ...
- DATE_FORMAT() 函数
DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据DATE_FORMAT(now(),'%Y-%m-%d %T')
- webservice 缓存机制
本文转载:http://blog.csdn.net/zhdd1234/article/details/4555472 WebService的缓存分为两种,一种是简单的输出缓存,一种是强大的数据缓存 一 ...
- 超级终端和SecureCRT进行Console口的连接
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...
- [Angular 2] Value Providers & @Inject
Dependecies aren’t always objects created by classes or factory functions. Sometimes, all we really ...
- Linux pipe函数
1. 函数说明 pipe(建立管道): 1) 头文件 #include<unistd.h> 2) 定义函数: int pipe(int filedes[2]); 3) 函数说明: pipe ...
- 【ZZ】一张图清晰追溯数据库的发展历程(1962-2016年)
http://www.cbdio.com/BigData/2016-02/24/content_4651751.htm 历史发展概述
- 出错处理完美搭配之perror&exit
对于库函数出错处理有两个十分有用的函数perror和exit: 一.错误报告 perror函数用一种简单统一的方式报告错误.ANSI C中的许多库函数,尤其是I/O函数,会调用操作系统去执行一些工作. ...
- Android之自定义AlertDialog无法监听控件
参考:http://www.cnblogs.com/511mr/archive/2011/10/21/2220253.html 要做一个自定义的弹出框,以前都是用一个Activity来实现,总觉得不是 ...
- RPC框架Thrift例子-PHP调用C++后端程序
更新 2016-02-22: Response对象不用主动创建. 前言 前段时间用了一下Facebook的开源RPC框架Thrift,做PHP客户端调用C++后端程序,真心觉得Thrift不错! 本文 ...