2 3 5 7 15 6 4 10296 936 1287 792 1
105 10296
#include<stdio.h> #include<iostream> using namespace std; long long lcd(long long n,long long m) { long long r; //scanf("%d%d",&n,&m); if(n<m)swap(n,m); long long p=n*m; while(m!=0) { r=n%m; n=m; m=r; } return p/n; } int main() { long long num[100]; int n1,n2,o; scanf("%d",&n1); while(n1--) { scanf("%d",&n2); for(int o=0;o<n2;o++) { scanf("%lld",&num[o]); } for(o=1;o<n2;o++) { num[o]=lcd(num[o],num[o-1]); } printf("%lld\n",num[o-1]); } }
原文地址:http://blog.csdn.net/qq754406613/article/details/43156805