转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud

C. Cupboard and Balloons

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

 

考虑到从下往上开始摆的空间利用率高,于是只需要考虑最终的顶上还能否再塞进一个气球即可。

 //#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std;
#define XINF INT_MAX
#define INF 0x3FFFFFFF
#define MP(X,Y) make_pair(X,Y)
#define PB(X) push_back(X)
#define REP(X,N) for(int X=0;X<N;X++)
#define REP2(X,L,R) for(int X=L;X<=R;X++)
#define DEP(X,R,L) for(int X=R;X>=L;X--)
#define CLR(A,X) memset(A,X,sizeof(A))
#define IT iterator
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<int> VI; int main()
{
ios::sync_with_stdio(false);
double r,h;
while(cin>>r>>h){
double tmp=(h+r/);
int ans=(int)(tmp/r+1e-);
tmp-=ans*r;
ans*=;
tmp+=r/;
if(tmp-r*(sqrt(3.0)/)>-1e-)ans++;
cout<<ans<<endl; }
return ;
}

代码君

codeforces 342C Cupboard and Balloons(公式题)的更多相关文章

  1. CodeForces 342C Cupboard and Balloons (几何问题)

    题意:给定一个 r 和 h,r 是上面那个半球的半径,h 是下面那个圆柱的高度,然后有一些半径为 r/2的气球,问你最多能放几个. 析:根据题意,很容易知道,先从下面往上放,两个两个的放,放到不能放的 ...

  2. Codeforces Round #199 (Div. 2) C. Cupboard and Balloons

    C. Cupboard and Balloons time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  3. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  4. Codeforces 828B Black Square(简单题)

    Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. ...

  5. http://codeforces.com/gym/100623/attachments E题

    http://codeforces.com/gym/100623/attachments E题第一个优化它虽然是镜像对称,但它毕竟是一一对称的,所以可以匹配串和模式串都从头到尾颠倒一下第二个优化,与次 ...

  6. 华东交通大学2018年ACM“双基”程序设计竞赛 C. 公式题 (2) (矩阵快速幂)

    题目链接:公式题 (2) 比赛链接:华东交通大学2018年ACM"双基"程序设计竞赛 题目描述 令f(n)=2f(n-1)+3f(n-2)+n,f(1)=1,f(2)=2 令g(n ...

  7. http://codeforces.com/gym/100623/attachments H题

    http://codeforces.com/gym/100623/attachments H题已经给出来的,包括后来添加的,都累加得到ans,那么从1-ans都是可以凑出来的,如果ans<a[n ...

  8. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  9. codeforces 340C Tourist Problem(公式题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Tourist Problem Iahub is a big fan of tou ...

随机推荐

  1. hdu5323 Solve this interesting problem(爆搜)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Solve this interesting problem Time Limit ...

  2. servlet 中字符集的处理

    Servlet运行的步骤 Servlet作为Web服务器的补充功能在运行时需要受到Servlet容器的管理,其运行的流程如下: 浏览器依据IP建立与容器的连接 浏览器将请求数据打包 容器解析请求数据包 ...

  3. 换行word-wrap与word-break兼容IE和FIREFOX -----设计师零张

    word-wrap是控制换行的.使用break-word时,是将强制换行.中文没有任何问题,英文语句也没问题.但是对于长串的英文,就不起作用.word-break是控制是否断词的.normal是默认情 ...

  4. C语言多维数组的地址

    设有整型二维数组a[3][4]如下: 0   1   2   3 4   5   6   7 8   9  10  11  它的定义为:     int a[3][4]={{0,1,2,3},{4,5 ...

  5. find the safest road--hdu1596

    find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. keil 中用函数指针调用函数的参数限制

    NSIC中,通过函数指针调用的函数的参数的个数没有限制,但是KeilC对此有限制,至多3个参数.因为,KeilC编译时,无法通过函数指针找到该函数的局部数据段,也就无法通过局部数据段传递参数,只能通过 ...

  7. 理解class.forName()(转)

    使用jdbc方式连接数据库时会使用一句代码Class.forName(String className).这句话是什么意思呢?首先说一点Class.forName(String className)这 ...

  8. linux查看系统版本和系统位数 (转)

    1. uname -ayou will view kernel name.network node hostname.kernel release.kernel version.machine har ...

  9. windows下搭建NFS服务器

    Win7除了旗舰版和企业版其他版本没有NFS客户端,windows2000,windowsXP,windows2003有个sfu(windows services for unix)工具貌似比较强大, ...

  10. 精确覆盖DLX算法模板

    代码 struct DLX { int n,id; int L[maxn],R[maxn],U[maxn],D[maxn]; ]; ) //传列长 { n=nn; ;i<=n;i++) U[i] ...