ACM (TJU) : 1528


#include <stdio.h>

long long gcd (long long x, long long y)
{
    if ( y == 0 )
    return x;
    else
    return gcd (y, x % y);
}

int main ()
{
    int dataSet;
    scanf ("%d", &dataSet);

    while ( dataSet-- ) {

        int m;
        scanf ("%d", &m);
        long long input, previous = 1;

        for ( int i = 0; i < m; i++ ) {
            scanf ("%lld", &input);
            previous = (input * previous) / gcd (input, previous);
        }

        printf ("%lld\n", previous);

    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s