poj 3970 Party 最小公倍数

题意:

给n个数,求它们的最小公倍数。

分析:

lcm(a,b)==a*b/gcd(a,b);

代码:

//poj 3970//sep9#include <iostream>using namespace std;typedef long long ll;ll gcd(ll a,ll b){return a%b==0?b:gcd(b,a%b);}int main(){int n;while(scanf("%d",&n)==1&&n){ll ans,x;scanf("%lld",&ans);–n;while(n–){scanf("%lld",&x);ans=ans*x/(gcd(ans,x));}if(ans>=1000000) puts("Too much money to pay!");else printf("The CEO must bring %lld pounds.\n",ans);}}

,会得到最大的满足,因为它填补了你的空虚。

poj 3970 Party 最小公倍数

相关文章:

你感兴趣的文章:

标签云: