Problem Description
Mr. B, Mr. G, Mr. M and their coach Professor S are planning their way to Warsaw for the ACM-ICPC World Finals. Each of the four has a square-shaped suitcase with side length Ai (1<=i<=4) respectively. They want to pack their suitcases into a large square box. The heights of the large box as well as the four suitcases are exactly the same. So they only need to consider the large box’s side length. Of course, you should write a program to output the minimum side length of the large box, so that the four suitcases can be put into the box without overlapping.
 
Input
Each test case contains only one line containing 4 integers Ai (1<=i<=4, 1<=Ai<=1,000,000,000) indicating the side length of each suitcase.
 
Output
For each test case, display a single line containing the case number and the minimum side length of the large box required.
 
Sample Input
2 2 2 2
2 2 2 1
 
Sample Output
Case 1: 4
Case 2: 4

Hint

For the first case, all suitcases have size 2x2. So they can perfectly be packed in a 4x4 large box without wasting any space. For the second case, three suitcases have size 2x2 and the last one is 1x1. No matter how you rotate or move the suitcases, the side length of the large box must be at least 4.

 #include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
double a[];
bool check(long long b)
{
if(b-a[]>=a[])
return true;
return false;
}
int main()
{
double maxn,minn,mid;
int t=;
while(cin>>a[]>>a[]>>a[]>>a[])
{
t++;
sort(a,a+);
minn=sqrt(a[]*a[]+a[]*a[]+a[]*a[]+a[]*a[]);
maxn=a[]*;
while(minn+0.1<maxn)
{
mid=(minn+maxn)/;
if(check(mid))maxn=mid;
else minn=mid;
}
printf("Case %d: %.0lf\n",t,minn);
}
return ;
}

HDU 4247 A Famous ICPC Team的更多相关文章

  1. HDU 4251 The Famous ICPC Team Again 主席树

    The Famous ICPC Team Again Problem Description   When Mr. B, Mr. G and Mr. M were preparing for the ...

  2. HDU 4251 The Famous ICPC Team Again(划分树)

    The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  3. hdu 4251 The Famous ICPC Team Again划分树入门题

    The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  4. HDOJ 4251 The Famous ICPC Team Again

    划分树水题..... The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 3276 ...

  5. 【HDOJ】4251 The Famous ICPC Team Again

    划分树模板题目,主席树也可解.划分树. /* 4251 */ #include <iostream> #include <sstream> #include <strin ...

  6. HDU4251-The Famous ICPC Team Again(划分树)

    Problem Description When Mr. B, Mr. G and Mr. M were preparing for the 2012 ACM-ICPC World Final Con ...

  7. HDU 2017 Multi-University Training Contest - Team 4 1009 1011

    Questionnaire Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)T ...

  8. HDU 5475(2015 ICPC上海站网络赛)--- An easy problem(线段树点修改)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5475 Problem Description One day, a useless calculato ...

  9. hdu 4255 A Famous Grid

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4255 A Famous Grid Description Mr. B has recently dis ...

随机推荐

  1. 一个经典的js中关于块级作用域和声明提升的问题

    function functions(flag) { if (flag) { function getValue() { return 'a'; } } else { function getValu ...

  2. python绝技 — 使用PyGeoIP关联IP地址和物理位置

    准备工作 要关联IP与物理位置,我们需要有一个包含这样对应关系的数据库. 我们可以使用开源数据库GeoLiteCity,它能够较为准确地把IP地址与所在城市关联起来 下载地址:http://dev.m ...

  3. Ubuntu 14.04 登陆界面循环问题解决

    今天手贱startx然后虚拟机就卡死了,再开输过密码就无限跳到登陆界面,其他账户可用.怀疑/home未挂载. 解决方法:(alf改成你的用户名) $ cd ~$ sudo chown alf:alf. ...

  4. js分页模板

    /** *参数说明: *currentPage:当前页数 *countPage:总页数 *changeMethod:执行java后台代码的js函数,即是改变分页数据的js函数 */ function  ...

  5. java 的序列化

    (1) 首先是java自己内部实现的对象序列化机制 其实就是ObjectInputStream 和 ObjectOutputStream 首先实现一个实体对象  记住必须实现Serializable ...

  6. python 数组过滤

    arr = [1,2,3,4,5,6,7,8,None]arr = [elem for elem in arr if elem != None]

  7. mysql的数据类型与列属性

  8. C#基础--值类型和引用类型

    C#中大多数类型都是引用类型,只有个别特殊情况是值类型. 值类型: 枚举(enum) 结构(struct) 基础类型:int, short, char, bool....(string是引用类型) 引 ...

  9. Facebook FB.init() status参数的作用

    意思是 status 设为 ture 之后调用 FB.getLoginStatus() 不再产生网络请求,数据已经在 FB.init() 调用的时候被请求回来,缓存住了.

  10. [M]带属性块参照的转换

    有一张表格,表格的每一行都由带有属性的块参照组成,如图: 魔法表格不能直接识别有块参照组成的表格,需要使用 EXPLODE 命令将块参照分解,但多分解带有属性的块只能得到属性的定义 这是就需要使用 B ...