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. 块元素block,内联元素inline; inline-block;

    block:块元素的特征 div ol li 等: 1.只有高度不设置宽度的时候默认撑满一行: 2.默认块元素不在一行: 3.支持所以CSS命令: inline:内联元素的特征 span i stro ...

  2. 转: requirejs压缩打包r.js使用示例 2 (~~很详细的教程)

    这一篇来认识下打包工具的paths参数,在入门一中 就介绍了require.config方法的paths参数.用来配置jquery模块的文件名(jQuery作为AMD模块时id为“jquery”, 但 ...

  3. php返回的json格式

    public function search_ip(){ $where['ip'] = $_GET['ip']; $Machine = M('Machine_info'); $arr = $Machi ...

  4. php 用户访问菜单页面,必须登录,判断用户是否登录

    <pre name="code" class="python"># 本节课大纲: 一.空模块和空操作 1.空操作 function _empty($ ...

  5. Hadoop Hive sql语法详解

    Hadoop Hive sql语法详解 Hive 是基于Hadoop 构建的一套数据仓库分析系统,它提供了丰富的SQL查询方式来分析存储在Hadoop 分布式文件系统中的数据,可以将结构 化的数据文件 ...

  6. C++动态数组的实现

    #include <iostream> using namespace std; int main() { int n; while(cin>>n) { ]; p[]=; p[ ...

  7. Objective-C基础教程读书笔记(6)

    第6章 源文件组织 到目前为止,我们讨论过的所有项目都是把源代码统统放入main.m文件中.类的main()函数,@interface和@implementation部分都被塞入同一个文件里.这种结构 ...

  8. volley源代码解析(七)--终于目的之Response&lt;T&gt;

    在上篇文章中,我们终于通过网络,获取到了HttpResponse对象 HttpResponse是android包里面的一个类.然后为了更高的扩展性,我们在BasicNetwork类里面看到.Volle ...

  9. DG创建和提取虚拟机文件

    http://www.cr173.com/soft/33359.html http://www.diskgenius.cn/help/newvmdk.php

  10. Java学习笔记:内部类/匿名内部类的全面介绍

    编写java程序时,一般一个类(或者接口)都是放在一个独立的java文件中,并且类名同文件名(如果类是public的,类名必须与文件名一致:非public得,无强制要求).如果想把多个java类放在一 ...