直接求就行
AC代码如下:
#include <iostream> using namespace std; int gcd( int a, int b ){ int temp; if( a < b ){ temp = a; a = b; b =temp; } while( b != 0 ){ temp = a % b; a = b; b = temp; } return a; } int lcm( int a, int b ){ int temp; temp = gcd( a, b ); return a / temp * b; } int main(){ int T, n, result, temp; cin >> T; while( T-- ){ cin >> n; result = 1; while( n-- ){ cin >> temp; result = lcm( result, temp ); } cout << result << endl; } return 0; }