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. POJ 3259:Wormholes bellman_ford判定负环

    Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 37906   Accepted: 13954 Descr ...

  2. tornado结合前端进行文件上传

    在表单中我们获取用户提交的数据,使用的是get_argument,复选框使用的是get_arguments,但是文件的不一样,文件的使用request.files. form文件上传 html代码: ...

  3. CSS隐藏商务通等内容

    CSS隐藏商务通等内容<style>#qiao-wrap{display:none !important;} </style>

  4. 搭建selenium+Python+eclipse 的开发环境

    下载安装Python,下载“python-2.7.9.msi”后可直接安装 下载安装setuptools,下载setuptools-11.3.1后,用命令提示符转到安装包中setup.py所在的位置, ...

  5. Centos7搭建SVN服务

    1.安装 subversion ​[root@CentOS var]# yum -y install subversion 2.创建 svn 版本库,初始化相关配置文件 ​[root@CentOS v ...

  6. POJ 3254:Corn Fields

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9295   Accepted: 4940 Descr ...

  7. mysql 免安装版后续操作

    在安装好mysql后,软件默认的root用户的密码为空. 1.进入mysql 2.创建数据库 3.创建表格 4.插入数据 5.显示数据库.表信息

  8. HTML的文档结构与语法(二)

    3.7 超链接标记 语法:<a 属性=“值”>对当前链接的描述</a>     作用:网页进行跳转 常用的属性: Href:链接的网址或ip或地址    值:就是具体的地址 T ...

  9. 转载-Logistic回归总结

     Logistic回归总结 作者:洞庭之子 微博:洞庭之子-Bing (2013年11月) 1.引言 看了Stanford的Andrew Ng老师的机器学习公开课中关于Logistic Regress ...

  10. 从零开始学C++(0 简介)

    2020年,给自己定一个新目标————开始写技术博客,将之前所学的内容重新复习并整理成一系列的文章,一来可以让自己对这些基础知识更加熟悉,二来方便于以后的复习查阅. 以前自己都是以笔记的形式将知识点记 ...