Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

Submit Status

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.

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 3000000
2 12 4
0

Sample Output

Too much money to pay!
The CEO must bring 12 pounds.

题意就是找各个数的最小公倍数。。。大于1000000的就输出too much。。。

水。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; int yue,cur,num,i,flag;
int test[200]; long long MaxY(long long x,long long y)
{ if (!x || !y)
return x > y ? x : y;
for (long long t; t = x % y; x = y, y = t)
;
return y;
} long long cal(long long a,long long b)
{
return (a*b)/yue;
} int main()
{
//freopen("i.txt","r",stdin);
//freopen("o.txt","w",stdout);
while(1)
{
cin>>num;
if(num==0)
break;
flag=1;
cur=1;
for(i=1;i<=num;i++)
{
cin>>test[i];
if(flag)
{
yue=MaxY(cur,test[i]);
cur=cal(cur,test[i]);
}
if(cur>=1000000)
{
flag=0;
}
}
if(flag)
cout<<"The CEO must bring "<<cur<<" pounds."<<endl;
else
cout<<"Too much money to pay!"<<endl;
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 3970:Party的更多相关文章

  1. POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)

    http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...

  2. POJ 3252:Round Numbers

    POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...

  3. POJ 1459:Power Network(最大流)

    http://poj.org/problem?id=1459 题意:有np个发电站,nc个消费者,m条边,边有容量限制,发电站有产能上限,消费者有需求上限问最大流量. 思路:S和发电站相连,边权是产能 ...

  4. POJ 3436:ACM Computer Factory(最大流记录路径)

    http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2* ...

  5. POJ 2195:Going Home(最小费用最大流)

    http://poj.org/problem?id=2195 题意:有一个地图里面有N个人和N个家,每走一格的花费是1,问让这N个人分别到这N个家的最小花费是多少. 思路:通过这个题目学了最小费用最大 ...

  6. POJ 3281:Dining(最大流)

    http://poj.org/problem?id=3281 题意:有n头牛,f种食物,d种饮料,每头牛有fnum种喜欢的食物,dnum种喜欢的饮料,每种食物如果给一头牛吃了,那么另一个牛就不能吃这种 ...

  7. POJ 3580:SuperMemo(Splay)

    http://poj.org/problem?id=3580 题意:有6种操作,其中有两种之前没做过,就是Revolve操作和Min操作.Revolve一开始想着一个一个删一个一个插,觉得太暴力了,后 ...

  8. POJ 3237:Tree(树链剖分)

    http://poj.org/problem?id=3237 题意:树链剖分.操作有三种:改变一条边的边权,将 a 到 b 的每条边的边权都翻转(即 w[i] = -w[i]),询问 a 到 b 的最 ...

  9. POJ 2763:Housewife Wind(树链剖分)

    http://poj.org/problem?id=2763 题意:给出 n 个点, n-1 条带权边, 询问是询问 s 到 v 的权值, 修改是修改存储时候的第 i 条边的权值. 思路:树链剖分之修 ...

随机推荐

  1. jsp快速回顾

    http://www.cnblogs.com/zfc2201/archive/2011/08/17/2143615.html http://blog.163.com/mount_lee/blog/st ...

  2. java#java.util.Date与java.time.LocalDateTime的转换

    转换主要通过Instant来进行的. Date date = new Date(); LocalDateTime localDateTime = LocalDateTime.ofInstant(dat ...

  3. 064、Java中递归调用

    01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...

  4. java.io.IOException: Error: JSP Buffer overflow

    错误 jsp页面报错如下: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java ...

  5. SQLserver 存储过程生成任意进制/顺序流水号

    ALTER    PROCEDURE [dbo].[TentoSerial] @num int, @ret nvarchar(10) output AS declare @StringXL nvarc ...

  6. IIC协议解析

    (1)概述 I2C(Inter-Integrated Circuit BUS) 集成电路总线,该总线由NXP(原PHILIPS)公司设计,多用于主控制器和从器件间的主从通信,在小数据量场合使用,传输距 ...

  7. Day 29:HTML常用标签

    软件的结构:  cs结构的软件的缺点:更新的时候需要用户下载更新包然后再安装,需要开发客户端与服务端.  cs结构软件的优点: 减轻服务端的压力,而且可以大量保存数据在客户端.  C/S(Client ...

  8. Redis 详解 (二) redis的配置文件介绍

    目录 1.开头说明 2.INCLUDES 3.MODULES 4.NETWORK 5.GENERAL 6.SNAPSHOTTING 7.REPLICATION 8.SECURITY 9.CLIENTS ...

  9. Java自学-集合框架 Comparator和Comparable

    Java Comparator和Comparable 步骤 1 : Comparator 假设Hero有三个属性 name,hp,damage 一个集合中放存放10个Hero,通过Collection ...

  10. ACM-可乐兑换

    题目描述:可乐兑换 小明的班级参加一个活动,每人要喝过一瓶可乐,恰逢可乐促销,3瓶可乐空瓶可以换一瓶可乐,小明想节约钱,所以想买尽可能少的可乐让每人至少喝过一瓶可乐,问买至少多少瓶可乐够n人至少每人喝 ...