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 ...
随机推荐
- 山东理工大学ACM平台题答案关于C语言 1580 闰年
闰年 Time Limit: 1000ms Memory limit: 32768K 有疑问?点这里^_^ 题目描述 时间过得真快啊,又要过年了,同时,我们的人生也增长了一年的阅历,又成熟了一些 ...
- 自己学会汉化DevExpress控件[转]
1. 文档导读 本文档以颜色区分内容的重要性和不同性,阅读本文档时请注意以下事项: 1. 红色部分表示需要注意的重点内容:(加粗的尤甚) 2. 蓝色部分表示相应于前版本新增的内容: 3. 紫色部分表示 ...
- Java数据库编程(JDBC)
一.使用Java对数据库的操作步骤: 1.根据应用程序的数据库类型,加载相应的驱动: 2.连接到数据库,得到Connection对象: 3.通过Connection创建Statement对象: 4.使 ...
- 深入Mysql 导入导出
mysql常用导出数据命令:1.mysql导出整个数据库 mysqldump -hhostname -uusername -ppassword databasename > backupfil ...
- python flask 部署
flask在开发的时候,经常启动本身进行调试(本身可以设置监听的端口,例如 在app.run(port=8088),当然默认不设置端口为5000). 但生产环境经常使用uswgi充当flask的宿主, ...
- Java模拟登陆新浪微博抓取数据【转载】
package com.shiyimm.crawler.weibo; import java.io.FileNotFoundException; import java.io.FileReader; ...
- 个人对maven pom.xml文件的理解
如:一个项目可能需要引用另外两个项目的类.. 如 项目cswebbefore 需要引用cswebservice 和reports 这三个项目都有各自的pom.xml文件 cswebservice 项 ...
- php中数组自定义排序
php中数组自定义排序方法有很多,现在只提usort();不会保留原有键名. unsort调用方法就是unsrot($arr,func); 注意: 如果func是写在当前类中的话,那么调用的方式是 u ...
- TFS服务器(微软源代码管理服务器)上彻底删除项目
在TFS服务器上建立了很多项目,发现在Team Explorer中,只能移除团队项目,这种移除,只是将项目从当前Team Explorer项目列表中删除,下一次Connect到TFS服务器时,或者刷新 ...
- qt 获取系统磁盘空间大小
quint64 getDiskFreeSpace(QString driver) { LPCWSTR lpcwstrDriver=(LPCWSTR)driver.utf16(); ULARGE_INT ...