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;
}

posted @ 2011-10-09 12:17  金海峰  阅读(181)  评论(0编辑  收藏  举报