C. Cupboard and Balloons
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

A girl named Xenia has a cupboard that looks like an arc from ahead. The arc is made of a semicircle with radius r (the cupboard's top) and two walls of height h (the cupboard's sides). The cupboard's depth is r, that is, it looks like a rectangle with base r and height h + rfrom the sides. The figure below shows what the cupboard looks like (the front view is on the left, the side view is on the right).

Xenia got lots of balloons for her birthday. The girl hates the mess, so she wants to store the balloons in the cupboard. Luckily, each balloon is a sphere with radius . Help Xenia calculate the maximum number of balloons she can put in her cupboard.

You can say that a balloon is in the cupboard if you can't see any part of the balloon on the left or right view. The balloons in the cupboard can touch each other. It is not allowed to squeeze the balloons or deform them in any way. You can assume that the cupboard's walls are negligibly thin.

Input

The single line contains two integers r, h (1 ≤ r, h ≤ 107).

Output

Print a single integer — the maximum number of balloons Xenia can put in the cupboard.

Sample test(s)
input
1 1
output
3
input
1 2
output
5
input
2 1
output
2
几何题,有点坑,有个地方没想清楚,一直wrong,我们可以先把长方形的那部分尽可能的多放,然后,我们可以,找到剩下的空间,刚好放两个球,和刚好放三个球的情况,这样,我们就可以得出公式了!
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std; int main()
{
double h,r;double temp=sqrt(3.0)/2.0;
while(scanf("%lf%lf",&r,&h)!=EOF){
int ans=2*(int)(h/r);
double t=h-ans/2.0*1.0*r;
//printf("%d %.6f %.6f\n",ans,t,temp*r);
if(t<r/2.0)ans++;
else if(t<temp*r)ans+=2;
else ans+=3;
printf("%d\n",ans);
}
return 0;
}

Codeforces Round #199 (Div. 2) C. Cupboard and Balloons的更多相关文章

  1. Codeforces Round #199 (Div. 2)

    A.Xenia and Divisors 题意:给定N个数,每个数的取值范围为1-7,N是3的倍数,判定是否能够恰好将N个数分成若干三元组,使得一个组中的元素a,b,c满足 a < b < ...

  2. Codeforces Round #199 (Div. 2) E. Xenia and Tree

    题目链接 2了,差点就A了...这题真心不难,开始想的就是暴力spfa就可以,直接来了一次询问,就来一次的那种,TLE了,想了想,存到栈里会更快,交又TLE了..无奈C又被cha了,我忙着看C去了.. ...

  3. Codeforces Round #199 (Div. 2) A Xenia and Divisors

    注意题目的数字最大是7 而能整除的只有 1,2,3,4,6,故构成的组合只能是1,2,4 或1,2,6或1,3,6,故分别统计1,2,3,4,6的个数,然后再分配 #include <iostr ...

  4. Codeforces Round #199 (Div. 2) B. Xenia and Spies

    B. Xenia and Spies time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #199 (Div. 2) D. Xenia and Dominoes

    把 'O' 看成 'X',然后枚举它的四个方向看看是否能放,然后枚举 $2^4$ 种可能表示每种方向是否放了,放了的话就标成 'X',就相当于容斥,对于新的图去dp. dp就是铺地砖,行用二进制来表示 ...

  6. Codeforces Round #515 (Div. 3)

    Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cs ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. 如何去掉Protel99se汉化菜单

    说明: 安装Protel99se汉化包后,卸载后重新安装也无法去掉汉化菜单.本文介绍解决办法. 问题: 网上一些Protel99se的安装包内,在介绍Protel安装时,采用3大步的方法.第一步安装P ...

  2. cmake 学习笔记(四)

    接前面的一二三,学习一下 CMakeCache.txt 相关的东西. CMakeCache.txt 可以将其想象成一个配置文件(在Unix环境下,我们可以认为它等价于传递给configure的参数). ...

  3. Java集合中对象排序

    集合中的对象排序需求还是比較常见的.当然我们能够重写equals方法,循环比較:同一时候Java为我们提供了更易使用的APIs.当须要排序的集合或数组不是单纯的数字型时,通常能够使用Comparato ...

  4. Jquery ajax方法详解

    1.url: 要求为string类型的参数,(默认为当前页面地址)发送请求的地址. 2.type: 要求为String类型的参数,请方式(get/post)默认为get.注意其他HTTP请求方法,例如 ...

  5. BZOJ 1455: 罗马游戏( 配对堆 + 并查集 )

    可并堆水题 --------------------------------------------------------- #include<bits/stdc++.h>   usin ...

  6. MyEclipse 引用其他项目及其jar包

    倘若在工作区有两个项目A和B,B项目引用A项目及其jar包(防止调用时A项目的方法出现NoClassFound),步骤如下: 在A项目上点右键看属性,点击Build Path--->Concon ...

  7. Linux怎么设置PostgreSQL远程访问

    原文链接: Linux怎么设置PostgreSQL远程访问 安装PostgreSQL数据库之后,默认是只接受本地访问连接.如果想在其他主机上访问PostgreSQL数据库服务器,就需要进行相应的配置. ...

  8. jquery倒计时自动跳转

    刚开始我用下面这种方法一直报错,不知是什么原因,就是多加了页面加载时调用这个方法,还请高手看到后小小留言解惑

  9. 同步fifo的verilogHDL设计实例

    原创 设计一个fifo,输入16bit,输出16bit的data,寻址宽度5bit,有空满标志. top 层如下所示: /* date : 2014/10/14 version : modelsim ...

  10. 使用webservice实现App与服务器端数据交互

    What? webservice曾经认为是解决异构系统间整合的最佳解决方案,不依赖于第三方任何系统的支持(不需要部署RDBMS服务器),大家只需要按照官方的规范,即可完成相互之间的数据交互. Why? ...