Ural-1084. Goat in the Garden(计算几何)
来源:互联网 发布:编辑书的软件 编辑:程序博客网 时间:2024/05/17 06:06
1084. Goat in the Garden
Time limit: 1.0 secondMemory limit: 64 MBSomeone has let a goat in a square kitchen-garden and had bound it to a stake. The stake is driven into the ground in the very midst of the square. The goat is hungry as a hunter and very voracious, and eats everything that can be reached without leaving the square and tearing off the rope. What area of the kitchen-garden will be ate round?Input
contains lengths of the garden sides and a cord length in meters (positive integers not exceeding 100, located in one line and separated with a space).Output
should contain an area of the kitchen-garden (in square meters to within 3 symbols after a decimal point), ate round by the goat.Sample
input output 10 6
95.091
题意:将一只羊拴在长为h的正方形的正中心,绳子长为r,羊能吃到草的面积
思路:当r<h/2时 area=PI*r*r;
当r>h/2*sqrt(2) area = h*h;
其他情况:area=(PI-4*acos(h/(2.0*r)))*r*r+2*sqrt(r*r-h*h/4.0)*h
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>using namespace std;const double PI = acos(-1);int main(){// freopen("in.txt","r",stdin);// freopen("out.txt","w",stdout); double h,r; scanf("%lf%lf",&h,&r); if(r>=h/2.0*sqrt(2.0)) { printf("%.3lf\n",h*h); } else if(r<=h/2.0) { printf("%.3lf\n",PI*r*r); } else { printf("%.3lf\n",(PI-4*acos(h/(2.0*r)))*r*r+2*sqrt(r*r-h*h/4.0)*h); } return 0;}
- Ural-1084. Goat in the Garden(计算几何)
- timus 1084. Goat in the Garden URAL 解题报告 计算几何
- ural 1084. Goat in the Garden
- ural 1084. Goat in the Garden math
- URAL 1348 Goat in the Garden 2计算几何(解题报告)
- ural 1348. Goat in the Garden 2
- ural 1084 Goat in the Garden
- Goat in the Garden (ural 1348)
- Ural 1084|Goat in the Gardon|计算几何
- GYM 100488 A. Yet Another Goat in the Garden(计算几何)
- Ural1084. Goat in the Garden
- URAL 1348 Goat in the Garden 2(点到线段的距离)
- timus 1348. Goat in the Garden 2 URAL 点到线段的距离
- URAL Goat in the Garden(圆与矩形求交集面积)
- URAL 1348 Goat in the Garden 2(点到线段的距离)
- URAL 1348. Goat in the Garden 2[求点到线段的距离]
- URAL 1084 || Goat in the Garden(同中心矩形与圆的公共面积
- 【点到线段距离】URAL - 1348 Goat in the Garden 2
- tomcat下各文件的作用及work目录
- 最新Linux 内核开发人员集体照
- WIN7下安装MYSQL时报Write configuration file错误
- 方滨兴校长在2013届本科生毕业典礼上的讲话(转)
- Ubuntu使用root管理员帐号登陆及在右键增加‘以管理员身份打开’ (转)
- Ural-1084. Goat in the Garden(计算几何)
- ARM数码管显示
- NEON ETM
- Median of Two Sorted Arrays
- 图的存储与拓扑排序
- 嵌入式 课程设计指导书
- 冒泡排序 java
- 如何使用Quartus II进行仿真
- 运算溢出