hdu 1019
来源:互联网 发布:p2p软件 编辑:程序博客网 时间:2024/05/22 15:37
#include<iostream>
using namespace std;
__int64 f(__int64 a,__int64 b)
{
__int64 t;
__int64 sum=a*b;
if(a<b)
{
t=a;
a=b;
b=t;
}
while(b)
{
t=a%b;
a=b;
b=t;
}
return sum/a;
}
int main()
{
int t,n;
__int64 x;
__int64 lcm;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%I64d",&lcm);
n--;
while(n--)
{
scanf("%I64d",&x);
lcm=f(lcm,x);
}
printf("%I64d\n",lcm);
}
return 0;
}
using namespace std;
__int64 f(__int64 a,__int64 b)
{
__int64 t;
__int64 sum=a*b;
if(a<b)
{
t=a;
a=b;
b=t;
}
while(b)
{
t=a%b;
a=b;
b=t;
}
return sum/a;
}
int main()
{
int t,n;
__int64 x;
__int64 lcm;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
scanf("%I64d",&lcm);
n--;
while(n--)
{
scanf("%I64d",&x);
lcm=f(lcm,x);
}
printf("%I64d\n",lcm);
}
return 0;
}
0 0
- hdu 1019
- hdu 1019
- hdu 1019
- hdu 1019
- hdu 1019
- hdu 1019
- HDU 1019
- hdu 1019
- HDU 1019
- hdu 1019
- HDU-1019
- hdu 1019
- hdu 1019
- hdu 1019
- hdu 1019
- hdu 1019解题报告
- hdu 1019最小公倍数
- hdu 1019 数学
- HDU 1002 之常见WA(C++描述)
- ALSA声卡驱动中的DAPM详解之一:kcontrol
- jQuery中attr和prop方法的区别
- Part3 使用JavaScript显示地图
- Hibernate 异常: Illegal attempt to associate a collection with two open sessions
- hdu 1019
- libgdx 进度条
- ALSA声卡驱动中的DAPM详解之三:如何定义各种widget
- 初识设计模式
- Cocos2d-x 3.0 编译出错 解决 error: expected ';' at end of member declaration
- Java 日期时间 Date类型,long类型,String类型表现形式的转换
- 函数热身(1)
- RESTful Webservice 和 SOAP Webserivce 对比及区别
- 如何删除数据库中重复的数据