POJ3970-Party
来源:互联网 发布:樱庭一树我的男人知乎 编辑:程序博客网 时间:2024/04/30 04:43
Party
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1258 Accepted: 482
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.
Source
Seventh ACM Egyptian National Programming Contest
简单地求最大公倍数
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int gcd(int x,int y){ if(x>y) return gcd(y,x); while(y%x) { int r=y%x; y=x; x=r; } return x;}int main(){ int n,x; while(~scanf("%d",&n)&&n) { int ans=1; for(int i=0;i<n;i++) { scanf("%d",&x); if(ans==-1) continue; int d=gcd(x,ans); ans=x*ans/d; if(ans>=1000000) ans=-1; } if(ans==-1) printf("Too much money to pay!\n"); else printf("The CEO must bring %d pounds.\n",ans); } 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
- ISO/OSI网络体系结构和TCP/IP协议模型
- 懂得借力使力
- GPU资源分配
- Java 常用工具代码
- Android ExpandableListView 中完美嵌套 GridView
- POJ3970-Party
- App Widget 学习
- 洛谷 P2168 荷马史诗
- 趣味编程题“马的智障”
- php向mysql中写入中文数据的问题
- gobeanstalk
- 初识cassandra数据库
- 【ThinkPHP系列篇】ThinkPHP框架使网页能够在浏览器中访问(二)
- 从零开始写C# MVC框架之--- 定义基类控制器、实现全局异常捕获