hdu 5858 Hard problem(2016 Multi-University Training Contest 10——数学题)
来源:互联网 发布:cx one4.41软件 编辑:程序博客网 时间:2024/05/21 08:38
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5858
Hard problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 253 Accepted Submission(s): 193
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
Author
BUPT
Source
2016 Multi-University Training Contest 10
解题思路:将问题转化成两个圆的相交的面积,再用内切圆的面积减去相交面积*2即可。
详见代码。
#include <bits/stdc++.h>using namespace std;#define MAX(x,y) ((x)>(y)?(x):(y))#define MIN(x,y) ((x)<(y)?(x):(y))#define ABS(x) ((x)>0?(x):(-(x)))#define ll long long#define N 250const int mod=1e9+7;const int inf=99999999;const double esp=1e-9;const double PI=acos(-1.0);/*int main(){ double a1,b1,r1,a2,b2,r2,d; double A1,A2,s1,s2,s; while(~scanf("%lf%lf%lf%lf%lf%lf",&a1,&b1,&r1,&a2,&b2,&r2)) { d=sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1)); //求圆心距 if(d>=r1+r2) printf("0.000\n"); //两圆相离或相外切 else if(d<=fabs(r1-r2))//内切或内含 { if(r1>r2) printf("%0.3lf\n",PI*r2*r2); else printf("%0.3lf\n",PI*r1*r1); } else { A1=2*acos((d*d+r1*r1-r2*r2)/(2*d*r1)); //用余弦定理求以圆心为顶点与两圆交点连线的角 A2=2*acos((d*d+r2*r2-r1*r1)/(2*d*r2)); s1=0.5*r1*r1*sin(A1)+0.5*r2*r2*sin(A2); s2=A1/2*r1*r1+A2/2*r2*r2; s=s2-s1; printf("%0.3lf\n",s); } }}*/int main(){ int t; double R,rr; double a1,b1,r1,a2,b2,r2,d; double A1,A2,s1,s2,s; scanf("%d",&t); while(t--) { scanf("%lf",&R); rr=R/2; a1=0,b1=R,r1=R; a2=rr,b2=rr,r2=rr; double ans; d=sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1)); //求圆心距 A1=2*acos((d*d+r1*r1-r2*r2)/(2*d*r1)); //用余弦定理求以圆心为顶点与两圆交点连线的角 A2=2*acos((d*d+r2*r2-r1*r1)/(2*d*r2)); s1=0.5*r1*r1*sin(A1)+0.5*r2*r2*sin(A2); s2=A1/2*r1*r1+A2/2*r2*r2; s=s2-s1; ans=s; double s1=R*R; double s2=PI*rr*rr; ans=(s2-ans)*2; printf("%.2lf\n",ans); } return 0;}
0 0
- hdu 5858 Hard problem(2016 Multi-University Training Contest 10——数学题)
- hdu 5867 Water problem(2016 Multi-University Training Contest 10——水题)
- hdu 5810 Balls and Boxes(2016 Multi-University Training Contest 7——数学题)
- HDU 6127 Hard challenge(思维+计算几何)——2017 Multi-University Training Contest
- HDU 5373 The shortest problem(模拟)——2015 Multi-University Training Contest 7
- (HDU 5734)Acperience <数学题> 2016 Multi-University Training Contest 2
- hdu 5802 Windows 10(2016 Multi-University Training Contest 6——贪心+dfs)
- hdu 5861Road(2016 Multi-University Training Contest 10——线段树+扫描线)
- hdu 5860 Death Sequence(2016 Multi-University Training Contest 10——递推)
- hdu 4947 A simple dynamic programming problem(2014 Multi-University Training Contest 10)
- hdu 4973 A simple simulation problem.(2014 Multi-University Training Contest 10)
- hdu 5733 tetrahedron(2016 Multi-University Training Contest 1——几何公式题)
- hdu 5745 La Vie en rose(2016 Multi-University Training Contest 2——暴力)
- hdu 5752 Sqrt Bo(2016 Multi-University Training Contest 3——水题)
- hdu 5753 Permutation Bo(2016 Multi-University Training Contest 3——组合)
- HDU 5755 Gambler Bo(高斯消元裸题)——2016 Multi-University Training Contest 3
- hdu 5763 Another Meaning(2016 Multi-University Training Contest 4——dp+kmp)
- hdu 5775 Bubble Sort(2016 Multi-University Training Contest 4——树状数组)
- 【u110】灾后重建
- 多态的实现原理
- Gallery 初体验
- Angular—ngRoute
- Libev事件库
- hdu 5858 Hard problem(2016 Multi-University Training Contest 10——数学题)
- 在Mac OS中安装 wget
- Spring学习(三)
- 对话框绝对居中(兼容IE8)
- libev整体设计
- MySQL5.6基本优化配置
- NppExec获取进程返回码
- colorhighlighter使用(sublime text3)
- Spring学习(四)