hdu1019--Least Common Multiple
简单题(只需要注意一下求公倍数时先除后乘)
代码如下:
#include<stdio.h>
int gcd(__int64 n,__int64 m)
{
if(m==0) return n;
return gcd(m,n%m);
}
int main()
{
int t,n;
__int64 x1,x2;
scanf("%d",&t);
while(t--)
{
scanf("%d %I64d",&n,&x1);
while(--n)
{
scanf("%I64d",&x2);
x1=x1/(gcd(x1,x2))*x2;
}
printf("%I64d\n",x1);
}
return 0;
}
转载于:https://www.cnblogs.com/pandy/archive/2008/10/24/1319050.html
hdu1019--Least Common Multiple相关推荐
- HDU 4913 Least common multiple
/* hdu4913 Least common multiple http://acm.hdu.edu.cn/showproblem.php?pid=4913 离散化 线段树 统计逆序数思想 tips ...
- 杭电2028--Lowest Common Multiple Plus
Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- Lowest Common Multiple Plus ——ACM
1. Lowest Common Multiple Plus 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.为每组测试数据输出它们的最小 ...
- hdoj-2028-Lowest common multiple plus
题目:Lowest common multiple plus 代码: #include<stdio.h> int common(int a,int b)//计算最大公约数 {int c=a ...
- HDOJ-1019 Least Common Multiple
Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...
- 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 ...
- Least Common Multiple
下面为 学长 大家公认的水题, 我比水题还睡 的 WA 了三遍 才成功在好队友的帮助下,A 了 杭电HDU Least Common Multiple Problem Description The ...
- 问题 A: Least Common Multiple
题目描述 The least common multiple (LCM) of a set of positive integers is the smallest positive integer ...
- 1.26(Least Common Multiple)
描述: Given A and B. Find the least positive M which is a common multiple of both A and B. 输入: Two pos ...
最新文章
- 非常好用的模糊pid温度控制算法_反应罐高低温温度控制装置
- 选择MPLS或SD-WAN用于组织网络部署的几大原因—Vecloud微云
- 大学本科电子信息工程专业核心课程与主干课程
- 常量元素记忆口诀_人体中的常量元素与微量元素
- css less 不要作用到子对象_CSS-预处理语言Sass、Less简述
- 83998 连接服务器出错_服务端 TCP 连接的 TIME_WAIT 问题分析与解决
- SpringBoot设置首页(默认页)跳转
- 无法移动或重命名“Documents and Settings”文件夹
- mysql 高性能架构_高性能MySQL之架构与历史(1)
- 对象新增方法 object.is() object.assign()
- 保护自己之手机定位信息收集
- SQL Server2005完全版与精简版的一个差别(抄录)
- 僵尸进程与孤儿进程(精简易懂,直接要害)
- CIC Dips Its Toe Back In US Waters
- 针式打印机打印发虚_针式打印机打印输出字符模糊不清晰的原因有哪些
- HTML跳转php没反应的问题解决
- 谈谈免费的仓库管理软件
- 通过3dmax将max文件导出为unity3d可用的带贴图的fbx文件
- 2021,自动驾驶的“五代十国”
- linux 指令熟悉
热门文章
- git中Bash基本操作命令
- mysql常用命令添加外键主键约束存储过程索引
- 浏览器,图片格式及特点
- CST,CET,UTC,GMT,DST,Unix时间戳几种常见时间概述与关系(转)
- java.lang.IllegalArgumentException: name MUST NOT NULL! at org.nutz.dao.impl.NutDao.fetch
- SuperMap 办公自动化服务平台
- Eclipse基础--java环境变量设置
- 8.最大滑动窗口问题
- Vue学习笔记之Nodejs中的NPM使用
- Django项目将debug模式设置为false时,静态文件出错