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. C++中cin输入类型不匹配解决方法

    #include <iostream> #include <set> using namespace std; int main() { int a; cin>>a ...

  2. hdu5344 MZL's xor(水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud MZL's xor Time Limit: 2000/1000 MS (Java/ ...

  3. 分享到QQ空间、新浪微博、腾讯微博的代码!

    给网页加上分享代码,借助网友的力量推广网站,目前已经很流行了 以下是网页代码 QQ空间分享代码如下: <a href="javascript:void(0);" onclic ...

  4. Linux - Reset a MySQL root password

    Use the following steps to reset a MySQL root password by using the command line interface. Stop the ...

  5. JAX-WS 学习二:基于WEB容器,发布WebService

    WebService 的发布通过调用 Endpoint.publish() 方法来启动一个java内嵌的WEB容器来实现的,如果要将WebService部署到一个WEB容器中去,需要使用jax-ws提 ...

  6. PHP foreach()跳出本次或当前循环与终止循环方法

    PHPforeach()跳出本次或当前循环与终止循环方法 PHP中用foreach()循环中,想要在循环的时候,当满足某个条件时,想 $arr = array('a','b','c','d','e') ...

  7. jQuery autocomplete 使用

    推荐 :http://www.cnblogs.com/Peter-Zhang/archive/2011/10/22/2221147.html eg: $("#txtGrand"). ...

  8. 平时的笔记02:处理mp3

    #! /usr/bin/env python # # mutagen aims to be an all purpose media tagging library # Copyright (C) 2 ...

  9. 《招聘一个靠谱的iOS》面试题参考答案(上)

    说明:面试题来源是微博@我就叫Sunny怎么了的这篇博文:<招聘一个靠谱的 iOS>,其中共55题,除第一题为纠错题外,其他54道均为简答题. 博文中给出了高质量的面试题,但是未给出答案, ...

  10. ARC 工作原理

    自动引用计数(Automatic Reference Counting),是一个编译期间工作的能够帮你管理内存的技术. ARC在编译期间为每个Objective-C指针变量添加合适的retain, r ...