TOJ:Least Common Multiple
来源:互联网 发布:人工智能豆瓣 编辑:程序博客网 时间:2024/05/22 03:18
1070: Least Common Multiple
Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByte
Total Submit: 2644 Accepted:928
Description
求n个数的最小公倍数。
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。
Sample Input
2 4 63 2 5 7
Sample Output
1270
Source
ZJGSU
#include<stdio.h>int main(){int n,a[1001],i,j,k,l,t;while(scanf("%d",&n)!=EOF){l = 1;for(i = 0; i < n; i++)scanf("%d",&a[i]);for(i = 0; i < n; i++){j = a[i];k = l;while(k){t = j % k;j = k;k = t;}l = l/j*a[i];}//辗转相除法 printf("%d\n",l);}return 0;}
0 0
- TOJ:Least Common Multiple
- toj 1528 Least Common Multiple
- HDU1019 Least Common Multiple
- Least Common Multiple
- 1019:Least Common Multiple
- 1019 Least Common Multiple
- HDU1019 ( Least Common Multiple )
- Least common multiple(H1019)
- 1019 Least Common Multiple
- Least Common Multiple 1019
- toj1528 Least Common Multiple
- Least Common Multiple
- Least Common Multiple
- hdu Least Common Multiple
- hdoj1019--Least Common Multiple
- AOJ41 Least Common Multiple
- HDOJ1019 Least Common Multiple
- hdu1019 Least Common Multiple
- 编程之美2014---大神与三位小伙伴
- Matlab:不包含边界和工具栏的figure(移除保存图片的白边)
- oracle 关闭、启动
- hdu 1166 敌兵布阵 解题报告
- hdu2235 机器人的容器
- TOJ:Least Common Multiple
- 图的广度优先遍历算法
- java中static的作用
- 选择排序算法中的交换数值问题
- c++ primer阅读笔记-15章-2
- 微软面试100题之20题:输入一个表示整数的字符串,把该字符串转换成整数并输出
- sort函数
- 点连通分量
- 不得不说的故事:STL内存管理