题目描述:
源码:
/**/ #include"iostream" using namespace std; int MinComMultiple(int n, int m) { int x, y, tmp; long long s; s = (long long)n * (long long)m;//避免int的乘积越界 if(n > m) { tmp = n; n = m; m = tmp; } tmp = m % n; while(tmp != 0) { m = n; n = tmp; tmp = m % n; } return s / n; } int main() { int n, m, result; int *p; cin>>n; for(int i = 0; i < n; i++) { cin>>m; p = new int[m]; for(int j = 0; j < m; j++)cin>>p[j]; result = p[0]; for(int j = 1; j < m; j++) { result = MinComMultiple(result, p[j]); } cout<<result<<endl; } return 0; }