HDU-5858:Hard problem(相交圆面积)
来源:互联网 发布:淘宝售前客服 编辑:程序博客网 时间:2024/05/21 22:53
Hard problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 753 Accepted Submission(s): 481
Problem Description
cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it?
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Give you the side length of the square L, you need to calculate the shaded area in the picture.
The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.
Input
The first line contains a integer T(1<=T<=10000), means the number of the test case. Each case contains one line with integer l(1<=l<=10000).
Output
For each test case, print one line, the shade area in the picture. The answer is round to two digit.
Sample Input
11
Sample Output
0.29
思路:利用模版求出半径为L的大圆的1/4与正方形内切圆的相交面积area,那么答案ans=2*(PI*L*L/4(内切圆的面积)-area)。
#include<bits/stdc++.h>using namespace std;const double PI=acos(-1.0);struct Point{ double x,y,r;}p[2];double dis(Point a,Point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double solve(Point a,Point b){ double d=dis(a,b); if(d>=a.r+b.r) return 0; else if(d<=fabs(a.r-b.r)) { double mn=min(a.r,b.r); return PI*mn*mn; } double ang1=acos((a.r*a.r+d*d-b.r*b.r)/(2.0*d*a.r)); double ang2=acos((b.r*b.r+d*d-a.r*a.r)/(2.0*d*b.r)); double area=a.r*a.r*ang1+b.r*b.r*ang2-d*a.r*sin(ang1); return area;}int main(){ int T;cin>>T; while(T--) { double L; cin>>L; p[0].x=0; p[0].y=L; p[0].r=L; p[1].x=L/2; p[1].y=L/2; p[1].r=L/2; double area=solve(p[0],p[1]); printf("%0.2lf\n",2*(PI*L*L/4-area)); } return 0;}
阅读全文
1 0
- HDU-5858:Hard problem(相交圆面积)
- HDU 5858 Hard problem 2016多校10 1002 [相交圆面积]【计算几何】
- HDU 5858 Hard problem【两圆的面积交】
- hdu-5120(两圆相交面积)
- hdu 5858 Hard problem
- hdu 5858 Hard problem
- HDU 5858 Hard Problem
- hdu 5858 Hard problem
- HDU 5858 Hard problem (几何)
- HDU-5858-Hard problem(几何)
- HDU 5858 Hard problem(计算几何)
- HDU 5858 Hard problem(计算几何)
- HDU 5858 Hard problem (公式推导)
- HDU-5858 Hard problem(计算几何)
- 数学题(Hard problem,HDU 5858)
- hdu 5120 Intersection(两圆相交面积)(模板)
- hdu 5120(容斥+圆相交部分面积)
- hdu 5120 Intersection(求相交圆的面积)
- 软件需求分析(百度百科)
- spring中配置数据源DBCP:basicDataSource和spring提供的DriverManagerDataSource的区别
- UEditor 自定义上传 远程服务器
- php开发微信公众号事件推送
- 服务器大体上的备份步骤及工作
- HDU-5858:Hard problem(相交圆面积)
- 零基础学图形学(14) 几何知识——Geometry源码
- 更换新口号 ,发力雄安,李彦宏在百度AI的黎明回望初心
- a标签加入点击事件
- 3-5 学生成绩统计
- 微信公众平台开发-消息管理-发送客服消息
- 复赛后第一次正经写博客
- 事物的七个传播特性
- 福利时刻,不可多得Java开发进阶必学资源,免费发放啦!!!