CodeForces 342C
来源:互联网 发布:淘宝外贸男装店推荐 编辑:程序博客网 时间:2024/04/29 17:31
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=121074#problem/C
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
1 1
3
1 2
5
2 1
2
思路:分三种情况讨论
令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;}
- CodeForces 342C
- CodeForces 342C Cupboard and Balloons
- Codeforces-340-C(c++)
- Codeforces-507-C(c++)
- CodeForces 731C C
- CodeForces-612C C
- CODEFORCES 265C CODEFORCES, 265C
- codeforces #78 div2 C
- Codeforces 117C Cycle
- CodeForces 209C
- CodeForces 156C Cipher
- codeforces 148 div2 C
- codeforces 242C
- Codeforces-234C Weather
- codeforces 106C Buns
- codeforces 158C
- Codeforces 243C
- CodeForces 13C Sequence
- python导入模块的4种方法
- CoordinatorLayout的详细介绍
- BufferedOutputStream 源码分析
- BaseAdapter学习
- 【爬虫-反爬虫】系列二:【文章精选1】-互联网网站的反爬虫策略浅析
- CodeForces 342C
- JAVA自学之每日一题(八)
- Vue.js学习思维导图一览
- Linux学习----vim编辑器
- pta-旅游规划
- ubuntu升级python,安装pip等基本软件
- 纯servlet+JSP+ztree+ajax+json开发城市列表
- BufferedInputStream与BufferedOutputStream用法简介
- Ojbect-C学习