CodeForces 342C

来源:互联网 发布:淘宝外贸男装店推荐 编辑:程序博客网 时间:2024/04/29 17:31

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=121074#problem/C

C - Cupboard and Balloons
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit Status Practice CodeForces 342C

Description

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 + r from 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 Input

Input
1 1
Output
3
Input
1 2
Output
5
Input
2 1
Output
2
题意:柜子里装气球:柜子规格如图,气球半径为r/2,给出r和h求能装多少气球

思路:分三种情况讨论

令gen=pow(3,0.5);(就是根3)

1 h%r<r/2  上面能放1个

2 h%r>=r/2&& h%r<gen*r/2 能放2个

3h%r>=gen*r/2 能放3个

#include<iostream>#include<cstdio>#include<queue>#include<string>#include<cstring>#include<vector>#include<cmath>using namespace std;typedef unsigned long long ull;int main(){    int r,h;    double gen=pow(3,0.5);    while(~scanf("%d%d",&r,&h)){        if(h%r<(double)r/2)cout<<(h/r)*2+1<<endl;        if(h%r>=(double)r/2&&h%r<gen*r/2)cout<<(h/r)*2+2<<endl;        if(h%r>=gen*r/2)cout<<(h/r)*2+3<<endl;    }    return 0;}


0 0
原创粉丝点击