poj3002

简单题

View Code
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;

int n;

long long gcd(long long x, long long y)
{
if (!x || !y)
return x > y ? x : y;
for (long long t; t = x % y; x = y, y = t);
return y;
}

void input()
{
long long ans = 1;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int a;
scanf("%d", &a);
ans = ans * a / gcd(ans, a);
}
if (ans <= 1000000000)
printf("%lld\n", ans);
else
printf("More than a billion.\n");
}

int main()
{
//freopen("t.txt", "r", stdin);
int t;
scanf("%d", &t);
while (t--)
{
input();
}
return 0;
}

你可能感兴趣的:(poj)