poj 3970 Party 最小公倍数
来源:互联网 发布:linux 挂载有数据硬盘 编辑:程序博客网 时间:2024/06/05 02:25
题意:
给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);}}
0 0
- poj 3970 Party 最小公倍数
- POJ 3970:Party
- POJ 3970Party
- POJ 3970(最小公倍数LCM)
- POJ 最小公倍数
- POJ 最小公倍数
- POJ 3663 costume party
- poj 2342 Anniversary party
- poj 3633 Costume Party
- POJ 2342 Anniversary party
- poj 2342 Anniversary party
- POJ 2342 Anniversary party
- poj 3663 Costume Party
- POJ 3663 Costume Party
- POJ 2342 Anniversary party
- POJ-2342-Anniversary party
- POJ Costume Party
- POJ-3663-Costume Party
- 用GLSL写一个8角花花
- memset函数的正确打开方式
- OpenCV入门之:Mat
- 【hadoop】 3006-hadoop对象序列化排序
- 二叉树中任意两个节点间的最大距离
- poj 3970 Party 最小公倍数
- css浮动
- Linux下的重要目录
- Git tips
- 4月3日毕设日记
- light oj 1067 Combinations (组合数的lucas定理)
- 字符转换
- 【hadoop】 3007-hadoop的提交job的源码分析
- QMdiArea 右键菜单