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. 运行ORB-SLAM笔记_使用篇(二)

    1. 编译完成之后就可以使用了,按照说明我们可以知道,首先开启roscore

  2. html5 canvas的教程

    原文地址:http://www.cnblogs.com/tim-li/archive/2012/08/06/2580252.html 原作很强悍 导航 前言 基本知识 绘制矩形 清除矩形区域 圆弧 路 ...

  3. DBCP连接池的使用

    1.新建工程 2.导入commons-dbcp commons-logging commons-pool这三个包 3.创建dbcpconfig.properties的文件 实例如下 #连接设置 dri ...

  4. centos tomcat 安装

    安装说明 安装环境:CentOS-6.3 安装方式:源码安装  软件:apache-tomcat-7.0.29.tar.gz 下载地址:http://tomcat.apache.org/downloa ...

  5. c#注释

    c#的注释分为:这里不能不说一下什么是注释. 注释本身不会执行,只是说明性文字,只供程序员阅读. 注释又分为:单行注释,多行注释,文档注释. 单行注释://开始 多行注释:/*开始, */结束. 文档 ...

  6. nginx 配置访问限制

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Helvetica Neue"; color: #454545 } p. ...

  7. Freeplane中的自动边线颜色功能

    今天我将电脑上的Freeplane从1.3.11升级到了1.5.18.发现新版本已经没有了1.3.11中的菜单选项Format → “Automatic edge color”.搜索了一下才发现,该功 ...

  8. 今天学习的裸板驱动之GPIO实验学习心得

    GPIO分成很多组今天学习的这个芯片的GPIO有GPA-GPJ个组.具体可在芯片手册中看到. GPIO有很多寄存器,今天学习的这个芯片,他的寄存器分为以下几种类型: (1)端口控制寄存器 (2)端口数 ...

  9. HTML中<title>与<h1>区别

    1)<title>标签表示的标题是整个网页的名字,即在浏览器顶部的tab栏里显示的.搜索引擎通过它来搜索网页:<title>标签里的文本不出现在页面内容里面. <h1&g ...

  10. ASP.NET 企业组织机构代码验证

    /// <summary> /// 组织机构代码验证 /// </summary> /// <param name="arg"></par ...