题目大意:求最小公倍数
Memory | Time | Language | Code Length |
216K | 0MS | C++ | 438B |
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
int lcm(int a, int b){
return a*b/gcd(a,b);
}
int main()
{
int a,b,d,num;
while(cin>>a&&a)
{
num=1;
while(a--)
{
cin>>b;
num=lcm(b,num);
}
if(num>=1000000)cout<<"Too much money to pay!"<<endl;
else
{
cout<<"The CEO must bring "<<num<<" pounds."<<endl;
}
}
return 0;
}