CDZSC_2015寒假新人(2)——数学 A
Description
Input
Output
Sample Input
3 5 7 15
6 4 10296 936 1287 792 1
Sample Output
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的更多相关文章
- CDZSC_2015寒假新人(2)——数学 P
P - P Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(2)——数学 H
H - H Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(2)——数学 G
G - G Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(2)——数学 D
D - D Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(2)——数学 C
C - C Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(2)——数学 B
B - B Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status ...
- CDZSC_2015寒假新人(1)——基础 i
Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...
- CDZSC_2015寒假新人(1)——基础 h
Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...
- CDZSC_2015寒假新人(1)——基础 g
Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...
随机推荐
- c++11 auto
auto 关键字指示编译器使用已声明变量的初始化表达式或 lambda 表达式参数来推导其类型. 在大多情况下,建议您使用 auto 关键字(除非您确实需要转换),因为此关键字可提供以下好处: 可靠性 ...
- C#将十六进制的文本转换到整型数据
1 length1 = Int32.Parse(szLine.Substring(1, 2), System.Globalization.NumberStyles.HexNumber);//计算这一行 ...
- (转)用Eclipse编译你的ROS程序
原地址: http://blog.csdn.net/sujun3304/article/details/18572017 好了,理解了系统各个组件的含义后,还是直接进入程序真刀真枪的从实践中学习吧! ...
- pair/sort/find/qsort
1. pair template <class T1, class T2> struct pair { typedef T1 first_type; typedef T2 second_t ...
- Hadoop1.2.1伪分布模式安装指南
一.前置条件 1.操作系统准备 (1)Linux可以用作开发平台及产品平台. (2)win32只可用作开发平台,且需要cygwin的支持. 2.安装jdk 1.6或以上 3.安装ssh,并配置免密码登 ...
- python文件批量改名
python对文件进行批量改名用到的是os模块中的listdir方法和rename方法. os.listdir(dir) :获取指定目录下的所有子目录和文件名 os.rename(原文件名,新文件名 ...
- Codeforces 582B Once Again
http://codeforces.com/contest/582/problem/B 题目大意:给出一个序列,是由一个长度为n的序列复制T次得到的,问最长非下降子序列的长度. 思路:我们建立一个n* ...
- LeetCode_Permutations
Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the follo ...
- Ubuntu下配置NFS服务
Table of Contents 1.下载相关软件 2.建立共享目录 3.修改该配置文件 4.重启服务 5.测试服务器 6.测试客户端 测试系统:Ubuntu8.04 1.下载相关软件 使用如下命令 ...
- 转:更新Android SDK之后Eclipse提示ADT版本过低的一个简易解决办法
拜GFW所赐,对于初学者的我来说,总会出现一些莫名其妙的问题 首先说明一下发表这一篇博文的“历史原因”吧,因为在更新SDK之后,进入Eclipse设置Android SDK目录的时候,会突然说我的版本 ...