** ****Planetary livemix** Time limit (Common/Java): 8000 MS/16000 MS running memory limit: 65536 Kbyte Total submission: 57 tested: 5 **Description** It is usually seen with the naked eye. When a planet is almost in a straight line, it is called a "planetary ball ". The N-star Concatenation refers to the fact that N planets in the solar system are in the same straight line at the same time. It is known that all the N planets are centered around the sun for a uniform circular motion, and the cycle of the I-th planet is Ti Day (that is, the time of a circle around the circumference ). Now, snow_storm wants to know the minimum interval between the appearance of N-star beads? **Input** The first positive integer T (t <= 300) indicates the number of test groups. For each group of test data, there is a positive integer N (2 <=n <=10000), Indicating that there are n planets In the next row, there are n positive integers Ti (1 <= Ti <= 10000). The number of I represents the revolution cycle of the I planet. **Output** For each group of test data, the minimum interval is output. **Sample Input** 3 3 5 6 7 4 2 4 6 8 4 5 6 30 60 **Sample output** Case 1: 210 Case 2: 24 Case 3: 60 **Question Source** Yb |

Question address:

Http: // 218.194.91.48/acmhome/problemdetail. do? & Method = showdetail & id = 1428

When I see this question, it is easy to know that it is to find the minimum public multiple of all numbers, but the product is very large.

So I was excited to write a Java big integer ~~~

N has not been written for a long time.

After knocking, submit, and RE in group 5th.

I checked N for a long time. I suspect that the data contains 0, except 0... Q: Why ~~

During the retrial, the N range was changed from 1000 to 10000...

(When the data range is 1000, my javaCodeIt should be Ac-enabled ~~~ Region ~ According to the author, the question data is out of water and the range is wrong ~~ Various Regions)

Taking the test method (Train of Thought) without luck, the author gave me the best TLE of my code ~~~ (The write method is incorrect ~)

Think about it, use C ++ instead (better than Java ...)...

The idea is very simple. First, enumerate all prime numbers within 100 (10000 after the start of 100 is 10000, so the sum of less than 100 certainly has a factor of less. Does not include the number of times, which is the prime number )...

Then record how many times each prime number appears in all numbers...

If the expression is repeated, the common factor is removed )...

Then we use the multiplication of large numbers to store the results. (Of course, we have also done it again. After that, we decided that when the number of new multiply entries is 1, do not multiply the number )...

Is it an AC? Although the data is really brutal...

Later, I changed the Java code ~~~~

========================================================== ========================================================== ======================================

C ++ code:

# Include <cstdio> # include <iostream> # include <cstring> # include <algorithm> using namespace STD; struct bigint {int Len, num [40000]; bigint () {} bigint (int x) {Len = 1; num [0] = x;} void MUL (int x) {int I; for (I = 0; I <Len; I ++) num [I] * = x; for (I = 0; I <len-1; I ++) if (Num [I]> = 100000) {num [I + 1] + = num [I]/100000; num [I] % = 100000;} If (Num [len-1]> = 100000) {num [Len] = num [len-1]/100000; num [len-1] % = 100000; Len ++ ;}} void print () {printf ("% d ", num [-- Len]); While (Len --) printf ("% 05d", num [Len]); puts ("") ;}}; int prime [11000]; int rec [110], CNT; int gcd (int x) {int I, J, K, num, res, M; Res = 1; for (I = 0; I <CNT & x> = rec [I]; I ++) {num = 0; while (X % rec [I] = 0) {num ++; x/= rec [I];} If (Num> 0) {If (Num <= prime [Rec [I]) continue; else {M = num-prime [Rec [I]; prime [Rec [I] = num; while (M --) RES * = rec [I] ;}} if (X & prime [x] = 0) {res * = x; prime [x] = 1;} return res;} int init _() {memset (Prime, 0, sizeof (PRIME); int I, j; CNT = 0; for (I = 2; I <= 100; I ++) {If (prime [I]) continue; For (j = I + I; j <= 100; j + = I) prime [J] = 1; REC [CNT ++] = I ;}} int init_1 () {memset (Prime, 0, sizeof (PRIME);} int A [11000]; int CMP (int x, int y) {return x> Y;} int main () {int T, TT, N, I, TMP; bigint res; scanf ("% d", & T); init _ (); For (TT = 1; TT <= T; TT ++) {init_1 (); scanf ("% d", & N); for (I = 0; I <n; I ++) scanf ("% d", & A [I]); sort (A, A + N, CMP); Res = bigint (A [0]); gcd (A [0]); for (I = 1; I <N; I ++) {TMP = gcd (A [I]); If (TMP = 1) continue; Res. mul (TMP);} printf ("case % d:", TT); Res. print ();} return 0 ;}

========================================================== ========================================================== ======================================

Java code:

Import Java. util. *; import Java. math. *; public class main {static int [] Prime = new int [11000]; static int [] rec = new int [110]; static int CNT; static int gcd (int x) {int I, J, K, num, res, M; Res = 1; for (I = 0; I <CNT & x> = rec [I]; I ++) {num = 0; while (X % rec [I]) = 0) {num ++; X/= rec [I];} If (Num> 0) {If (Num <= prime [Rec [I]) continue; else {M = num-prime [Rec [I]; prime [Rec [I] = num; while (M> 0) {M --; res * = rec [I] ;}}} if (x> 1 & prime [x] = 0) {res * = X; prime [x] = 1;} return res;} static void init _ () {int I, j; for (I = 0; I <= 100; I ++) prime [I] = 0; CNT = 0; for (I = 2; I <= 100; I ++) {If (prime [I] = 1) continue; for (j = I + I; j <= 100; j + = I) prime [J] = 1; REC [CNT ++] = I ;}} public static void main (string ARGs []) {program CIN = new program (system. in); int T, TT, N, J, I, TMP, M; biginteger res, now; t = cin. nextint (); init _ (); For (TT = 1; TT <= T; TT ++) {for (j = 0; j <= 10000; j ++) prime [J] = 0; n = cin. nextint (); TMP = cin. nextint (); Res = biginteger. valueof (TMP); gcd (TMP); for (I = 1; I <n; I ++) {TMP = cin. nextint (); M = gcd (TMP); If (M = 1) continue; Res = res. multiply (biginteger. valueof (m);} system. out. println ("case" + tt + ":" + Res );}}}