1407291736-hd-Lowest Common Multiple Plus.cpp
来源:互联网 发布:淘宝二手回收骗局 编辑:程序博客网 时间:2024/06/16 10:03
#include<stdio.h>
__int64 s[1000];
__int64 gcd(__int64 a,__int64 b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
int n;
__int64 sum,j;
int i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%I64d",&s[i]);
sum=1;
for(i=0;i<n;i++)
{
j=sum*s[i];
//当变量的值改变的时候,下面再次引用变量的时候要格外注意
j/=gcd(sum,s[i]);
sum=j;
}
printf("%I64d\n",sum);
}
return 0;
}
__int64 s[1000];
__int64 gcd(__int64 a,__int64 b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
int n;
__int64 sum,j;
int i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%I64d",&s[i]);
sum=1;
for(i=0;i<n;i++)
{
j=sum*s[i];
//当变量的值改变的时候,下面再次引用变量的时候要格外注意
j/=gcd(sum,s[i]);
sum=j;
}
printf("%I64d\n",sum);
}
return 0;
}
0 0
- 1407291736-hd-Lowest Common Multiple Plus.cpp
- hd 2028 Lowest Common Multiple Plus
- Lowest Common Multiple Plus hd 2028
- 杭电Hd 2028 Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- Lowest Common Multiple Plus
- 2028 Lowest Common Multiple Plus
- 【hdoj2028】Lowest Common Multiple Plus
- [APUE]第九章 进程关系
- Python中下划线---完全解读
- ACM斗牛游戏算法JAVA实现
- Zend studio快捷键使用
- 密码改变人生
- 1407291736-hd-Lowest Common Multiple Plus.cpp
- http://poj.org/problem?id=1001
- 现在网站太无趣了
- struts2.1.8+hibernate3.2+Spring3.0+ExtJs4.2+MySql+WebSocket 更新
- IOS编程之通讯录
- 关于GET和POST请求
- 将数据库表导出到excel中
- VS 2010下 打开实例 出现这样的错误: LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- 手把手教你玩转网络编程模型之完成例程(Completion Routine)篇(上)