题目链接:
In a strange planet there are n races. They are completely different as well as their food habits. Each race has a food-eating period. That means the ith race eats after every xi de-sec (de-sec is the unit they use for counting time and it is used for both singular and plural). And at that particular de-sec they pass the whole day eating.The planet declared the de-sec as 'Eid' in which all the races eat together.Now given the eating period for every race you have to find the number of de-sec between two consecutive Eids.InputInput starts with an integer T (≤ 225), denoting the number of test cases.Each case of input will contain an integer n (2 ≤ n ≤ 1000) in a single line. The next line will contain n integers separated by spaces. The ith integer of this line will denote the eating period for the ith race. These integers will be between 1 and 10000.OutputFor each case of input you should print a line containing the case number and the number of de-sec between two consecutive Eids. Check the sample input and output for more details. The result can be big. So, use big integer calculations.Sample Input232 20 1045 6 30 60Output for Sample InputCase 1: 20Case 2: 60
题目大意:给出n个数 求n个数的最小公倍数;
思路:求最小公倍数可以用最大公约数来求,但是由于n的大小与每个数的大小,所以最后说求得最小公倍数可能是个大数,所以需要用到大数相乘;
利用每个数的因子求最小公倍数。例如:
5 的因子 5;
6的因子 2 3;
30的因子 2 3 5;
60的因子 2 2 3 5;
保存出现的每个因子最大个数 2个2 1个3 1个5 相乘就得到最小公倍数 60;
#include#include #include #include #include #include #include #include