HDU ACM 11 2028 求N个数的最小公倍数

#include 
using namespace std;
int Lu(int a, int b)
{
    int temp;
    if (a < b)
    {
        temp = a;
        a = b;
        b = temp;
    }
    if (a%b == 0)
        return b;
    else
        return Lu(b, a%b);
}

int Zheng(int a, int b)
{
    return a/Lu(a, b)*b;
}

int main()
{
    int n, m , s;
    while (cin >> n)
    {
        s = 1;
        for (int i = 0; i < n; i++)
        {
            cin >> m;
            s = Zheng(s, m);
        }
        cout << s << endl;
    }
    return 0;
}

你可能感兴趣的:(HDU ACM 11 2028 求N个数的最小公倍数)