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. HihoCoder第五周:标准动态规划

    这周的题目是最标准最简单的动态规划了,自己一直以来对动态规划都不是很理解,这次也是好好记录一下. 题目1 :数字三角形 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 问题描述 ...

  2. Minikube安装

    参考 https://blog.csdn.net/liumiaocn/article/details/52041726?locationNum=4&fps=1 中文社区API http://d ...

  3. es678910语法糖

    傲娇: 新es是js的进步,是编程的进步,es6已经过去了5年了,兼容率达到了90%,还是有10%的手机不兼容,那到底应不应该去照顾那些跟不上的人,我觉得是不应该的,新es能5行写出来的功能,我为什么 ...

  4. Java集合基于JDK1.8的ArrayList源码分析

    本篇分析ArrayList的源码,在分析之前先跟大家谈一谈数组.数组可能是我们最早接触到的数据结构之一,它是在内存中划分出一块连续的地址空间用来进行元素的存储,由于它直接操作内存,所以数组的性能要比集 ...

  5. System.Data.SqlClient.SqlException: 'Incorrect syntax near 'OFFSET'.

    https://www.nopcommerce.com/boards/t/54586/410-not-running-on-local-system.aspx#209684 Hello, I was ...

  6. MongoDB_01

    解释:MongoDB可应对 --三高需求 High performance-对数据库高并发读写的需求 Huge Storage -对海量数据的高效率存储和访问的需求 High Scalability ...

  7. tornado+peewee-async+peewee+mysql(一)

    前言: 需要异步操作MySQL,又要用orm,使用sqlalchemy需要加celery,觉得比较麻烦,选择了peewee-async 开发环境 python3.6.8+peewee-async0.5 ...

  8. 030-PHP日期查询函数

    <?php , , ))//检查日期函数 { print("2,18,1970 :" . "这是一个正确的日期格式"); } else { print(& ...

  9. 079-PHP数组排序,两次循环法封装成函数

    <?php function mysort($arr){ //将排序的代码封装为函数 echo '<br />数组排序之前的信息:<br />'; print_r($ar ...

  10. css渐变实现

    body{ width: 100%; height: 100%; overflow: hidden; } *{ margin: 0px; padding: 0px; font-size: 0px; } ...