POJ3970 Party
来源:互联网 发布:gotv 倚天屠龙记 源码 编辑:程序博客网 时间:2024/04/30 06:17
Party
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1300 Accepted: 498
Description
The CEO of ACM (Association of Cryptographic Mavericks) organization has invited all of his teams to the annual all-hands meeting, being a very disciplined person, the CEO decided to give a money award to the first team that shows up to the meeting.
The CEO knows the number of employees in each of his teams and wants to determine X the least amount of money he should bring so that he awards the first team to show up such that all team members receive the same amount of money. You must write a program to help the CEO achieve this task.
The CEO knows the number of employees in each of his teams and wants to determine X the least amount of money he should bring so that he awards the first team to show up such that all team members receive the same amount of money. You must write a program to help the CEO achieve this task.
Input
The input consists of multiple test cases, each test case is described on a line by itself, Each line starts with an integer N (1 <= N <= 20) the number of teams in the organization followed by N space separated positive integers representing the number of employees in each of the N teams. You may assume that X will always fit in a 32 bit signed integer. The last line of input starts with 0 and shouldn't be processed.
Output
For each test case in the input print "The CEO must bring X pounds.", where X is as described above or "Too much money to pay!" if X is 1000000 or more.
Sample Input
1 30000002 12 40
Sample Output
Too much money to pay!The CEO must bring 12 pounds.
一共N支队伍来参加聚会,不知道哪只队伍先来,对先来的队伍给予奖励,要求队伍内队员可以平分,求最少的钱数,
很明显求最小公倍数,欧几里得算法。
代码如下:
#include <iostream>using namespace std;int gcd(int a,int b){ return b? gcd(b,a%b):a;}int main(){ int n,tmp,lcm; int date[21]; while(cin>>n) { if(n==0) break; for(int i=0;i<n;i++) { cin>>date[i]; } tmp=date[0]; for(int i=1;i<n;i++) { lcm=tmp*date[i]/gcd(tmp,date[i]); tmp=lcm; } if(tmp>=1000000) cout<<"Too much money to pay!"<<endl; else cout<<"The CEO must bring "<<tmp<<" pounds."<<endl; } return 0;}
0 0
- POJ3970-Party
- POJ3970 Party
- Party
- Party
- Party
- Party
- Party
- CodeForces Gym 100646D Party Party Party
- Anniversary party
- JOJ2701 Party
- Party Lamps
- C2. Party
- B. Party
- BOOL party
- Anniversary Party
- Hobbits' Party
- Party Lamps
- hdu3062 Party
- 微服务架构(一):单一应用架构与微服务架构
- linux安装环境初始化配置
- X3850 b报错:No Op ROM Space
- 关于移动赠送的CMCC,能连接和登录,但登录后仍上不了网的问题
- 二叉搜索树的创建,插入式创建4.1
- POJ3970 Party
- 2515 2014年中山市选拔赛 投票
- 深入Java集合学习系列:HashMap的实现原理http://zhangshixi.iteye.com/blog/672697
- 找规律-洛谷P1227 [JSOI2008]完美的对称
- 电商那些年,我摸爬打滚出的高并发架构实战精髓
- c++与C#中的抽象类
- TypeScript 基本语法
- eclipse 用adb shell ps 命令检测某个应用的资源占用
- 好文推荐:程序猿不应该只会敲代码,否则几年后你依然平平庸庸