链接http://vjudge.net/problem/Aizu-NTL_1_C
题意
求一个数组的最小公倍数,直接套模板.
#include<stdio.h>
#define ll long long
using namespace std;
const int maxn=100;
ll f[maxn];
ll n;
inline ll gcd(ll a,ll b){
while(b){
ll t=a%b;
a=b;
b=t;
}
return a;
}
inline ll lcm(ll a,ll b){
return (a*b/gcd(a,b));
}
ll nlcm(ll *f,int n){
if(n==0)
return f[0];
return lcm(f[n-1],nlcm(f,n-1)) ;
}
int main(){
scanf("%lld",&n);
for(ll i=0;i<n;i++)
scanf("%lld",&f[i]);
printf("%lld\n",nlcm(f,n));
return 0;
}