A - A

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.

 

Input

Input will consist of multiple problem instances. The first line of the input will contain a single integer indicating the number of problem instances. Each instance will consist of a single line of the form m n1 n2 n3 ... nm where m is the number of integers in the set and n1 ... nm are the integers. All integers will be positive and lie within the range of a 32-bit integer. 
 

Output

For each problem instance, output a single line containing the corresponding LCM. All results will lie in the range of a 32-bit integer. 
 

Sample Input

2
3 5 7 15
6 4 10296 936 1287 792 1
 

Sample Output

105
10296
 
 #include<iostream>
#include<cstdio>
using namespace std;
int LCM(int a,int b)
{
int m=a,n=b;
int c;
while(b!=)//辗转相除法
{
c=a%b;
a=b;
b=c;
}
return m/a*n;//之前写的m*n/a 结果是错的 改成这样之后终于AC了
}
int main()
{
int a,n,m,num;
scanf("%d",&n);
while(n--)
{
num=;
scanf("%d",&m);
while(m--)
{
scanf("%d",&a);
num=LCM(a,num);
}
printf("%d\n",num);
}
}

CDZSC_2015寒假新人(2)——数学 A的更多相关文章

  1. CDZSC_2015寒假新人(2)——数学 P

    P - P Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  2. CDZSC_2015寒假新人(2)——数学 H

    H - H Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  3. CDZSC_2015寒假新人(2)——数学 G

    G - G Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. CDZSC_2015寒假新人(2)——数学 D

    D - D Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  5. CDZSC_2015寒假新人(2)——数学 C

    C - C Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  6. CDZSC_2015寒假新人(2)——数学 B

    B - B Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  7. CDZSC_2015寒假新人(1)——基础 i

    Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...

  8. CDZSC_2015寒假新人(1)——基础 h

    Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...

  9. CDZSC_2015寒假新人(1)——基础 g

    Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...

随机推荐

  1. SMBUS(IIC)总线

    1.SPI和IIC一般都作为板上通信,UART.SMBUS和USB一般都作为板间通信. 其中SMBUS是参考IIC制定出来的眼生病,两者很像. 2.SMBUS的I/O接口是由两条线组成的双向串行总线. ...

  2. paip.输入法编程----一级汉字1000个

    paip.输入法编程----一级汉字1000个.txt 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn. ...

  3. ext4 grid edit 添加删除行

    extjs--grid动态添加一行和删除一行: (1)选择rowEditing时,添加一行后的编辑方式为----startEdit(record,columnHeader) (2)选择cellEdit ...

  4. 用委托、匿名函数、Lambda的方式输出符合要求的数

    最近看了一些博客,对委托和匿名函数和Lambda的方式有了一些更深的理解,在前人的基础上.我也写3个例子 using System; using System.Collections.Generic; ...

  5. Oracle主键约束、唯一键约束、唯一索引的区别

    一般,我们看到术语“索引”和“键”交换使用,但实际上这两个是不同的.索引是存储在数据库中的一个物理结构,键纯粹是一个逻辑概念.键代表创建来实施业务规则的完整性约束.索引和键的混淆通常是由于数据库使用索 ...

  6. a:hover和a:visited书写顺序的重要性

    2a:hover和a:visited书写顺序的重要性今天在用a:hover属性的时候发现一个奇怪的问题,同一个页面里面有些链接的a:hover效果不能正常表现出来.链接的代码是一样,没有使用其它样式固 ...

  7. mysql 命令行 自动补全

    配置文件中 默认关闭自动补全: [mysql] #no-auto-rehash # faster start of mysql but no tab completition 改为: [mysql] ...

  8. sign starfieldtech

    signtool sign /f certfile.pfx /p password /tr http://tsa.starfieldtech.com /td SHA256 mycode.exe htt ...

  9. 06_Elasticsearch 批量获取mget

    06_Elasticsearch 批量获取mget 现在有: http://192.168.32.81:9200/bank/bank_account/1 http://192.168.32.81:92 ...

  10. hdu1067-Gap(bfs+哈希)

    Let's play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit ...