题目传送门

Hard problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1066    Accepted Submission(s): 622

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.

 
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
1
1
 
Sample Output
0.29
 
Author
BUPT
 
Source
 
Recommend
wange2014
题意:求阴影部分面积
题解:求圆与圆相交面积的模板
代码:
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<stdio.h>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> PII;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
//head
const double PI=acos(-);
struct Round{
double x,y;
double r;
}c1,c2;
double dis(Round a,Round b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double solve(Round a,Round b)
{
double d=dis(a,b);
double ang1=acos((a.r*a.r+d*d-b.r*b.r)//a.r/d);
double ang2=acos((b.r*b.r+d*d-a.r*a.r)//b.r/d);
double ret=ang1*a.r*a.r+ang2*b.r*b.r-d*a.r*sin(ang1);
return ret;
}
int main()
{
c1.x=0.5,c1.y=0.5,c1.r=0.5;
c2.x=,c2.y=,c2.r=;
double sum=solve(c1,c2);
sum=PI*0.5*0.5-sum;
sum=sum*;
int T;
scanf("%d",&T);
int L;
while(T--)
{
scanf("%d",&L);
printf("%.2f\n",sum*L*L);
} return ;

下面是两圆求相交面积的模板

const double PI  =  acos(-);

struct Round {
double x, y;
double r;
}c1,c2; double dis(Round a, Round b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
} double solve(Round a, Round b)
{
double d = dis(a, b);
if (d >= a.r + b.r) return ; if (d <= fabs(a.r - b.r))
{
double r = a.r < b.r ? a.r : b.r;
return PI * r * r;
} double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / . / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / . / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
}

hdu5858 Hard problem(求两圆相交面积)的更多相关文章

  1. POJ 2546 &amp; ZOJ 1597 Circular Area(求两圆相交的面积 模板)

    题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...

  2. 求两圆相交部分面积(C++)

    已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...

  3. hdu 5120 (求两圆相交的面积

    题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...

  4. poj2546Circular Area(两圆相交面积)

    链接 画图推公式 这两种情况 都可用一种公式算出来 就是两圆都求出圆心角 求出扇形的面积减掉三角形面积 #include <iostream> using namespace std; # ...

  5. [hdu 3264] Open-air shopping malls(二分+两圆相交面积)

    题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...

  6. hdu 3264 Open-air shopping malls(圆相交面积+二分)

    Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  7. poj 2546(两圆公共面积)

    Circular Area Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5682   Accepted: 2225 Des ...

  8. 两圆相交求面积 hdu5120

    转载 两圆相交分如下集中情况:相离.相切.相交.包含. 设两圆圆心分别是O1和O2,半径分别是r1和r2,设d为两圆心距离.又因为两圆有大有小,我们设较小的圆是O1. 相离相切的面积为零,代码如下: ...

  9. HDU 3467 (求五个圆相交面积) Song of the Siren

    还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...

随机推荐

  1. 四轴飞行器飞行原理与双闭环PID控制

    四轴轴飞行器是微型飞行器的其中一种,相对于固定翼飞行器,它的方向控制灵活.抗干扰能力强.飞行稳定,能够携带一定的负载和有悬停功能,因此能够很好地进行空中拍摄.监视.侦查等功能,在军事和民用上具备广泛的 ...

  2. MYSQL学习笔记——常用语句

    1.检索数据 1.1.检索单个列:SELECT prod_name FROM products; 1.2.检索多个列:SELECT prod_id, prod_name, prod_price FRO ...

  3. 洛谷P2606 [ZJOI2010]排列计数 组合数学+DP

    题意:称一个1,2,...,N的排列P1,P2...,Pn是Magic的,当且仅当2<=i<=N时,Pi>Pi/2. 计算1,2,...N的排列中有多少是Magic的,答案可能很大, ...

  4. k8s+jenkins

    1 server 的port , targetport, nodeport的区别 targetport为容器的暴露端口,为最后端的端口 port可以理解为pod的端口,pod是容器的外层,该端口可以在 ...

  5. Kettle日志级别

    Kettle的日志级别LogLevel分为以下几个: Nothing 没有日志 不显示任何输出 Error 错误日志 仅仅显示错误信息 Minimal 最小日志 使用最小的日志 Basic 基本日志 ...

  6. Flink 在人工智能领域的应用实践

    人工智能是未来十年最重要的技术革命与驱动力,在各行各业产生着日益重要的作用,它与大数据的发展相辅相成,不仅推动人类社会迈入更智慧的世界,也为数据的应用带来无可估量的价值. 11 月 28 - 30 日 ...

  7. 整数解 (hdu 2092

    整数解 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  8. python-zx笔记9-单元测试

    unittest核心要素 1.TestCase 一个TestCase的实例就是一个测试用例.什么是测试用例呢?就是一个完整的测试流程,包括测试前准备环境的搭建(setUp),执行测试代码(run),以 ...

  9. 杂项 List

    题目 1. 栈    #A 表达式的转换 (Unaccepted) 2. STL 模板库 #B 双栈排序(Unaccepted)    #C 垃圾陷阱(Accepted)    #D 合并果子(Acc ...

  10. map()函数用法

    需求:已知两个列表,现在要一个列表中的元素,分别全部插入另一个列表中,新列表是[[0, 9, 1], [0, 9, 2], [0, 9, 3], [0, 9, 4], [0, 9, 5], [0, 9 ...