题目传送门

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. 自定义、操作cookie

    /** * 读取所有cookie * 注意二.从客户端读取Cookie时,包括maxAge在内的其他属性都是不可读的,也不会被提交.浏览器提交Cookie时只会提交name与value属性.maxAg ...

  2. Python Paramiko模块使用

    1 执行远程命令 #!/usr/bin/python import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_polic ...

  3. Debug to add expression

    Debug expression

  4. Linux中的sshd服务

    Linux中的sshd服务,主要用于pst终端,远程连接到linux服务中 看sshd服务状态 service sshd status 停止sshd服务 service sshd stop 启动ssh ...

  5. js如何判断用户使用的设备类型及平台

    前端开发经常遇到需要判断用户的浏览设备,是pc端还是移动端,移动端使用的是什么手机系统?android.ios.ipad.windows phone等等,有时候还需要知道用户浏览页面是在微信中打开还是 ...

  6. python进阶:装饰器

    1.闭包 简单理解:闭包就是多层函数的嵌套,外层函数的返回值是内层函数的引用. def out_func(n): num = 100 def in_fucn(*args,**kwargs): # no ...

  7. BZOJ 3879: SvT 虚树 + 后缀自动机

    Description (我并不想告诉你题目名字是什么鬼) 有一个长度为n的仅包含小写字母的字符串S,下标范围为[1,n]. 现在有若干组询问,对于每一个询问,我们给出若干个后缀(以其在S中出现的起始 ...

  8. Xcode之增加环境变量(多种环境区分)

    序言: Xcode默认有DEBUG何RELEASE模式,如果我们在项目中想增加预发布环境或者再增加多个环境呢?如果在项目中用if else 弄个全局变量来控制,每次打包之前去手动修改,这样不仅繁琐,而 ...

  9. 【2019 Multi-University Training Contest 9】

    01: 02:https://www.cnblogs.com/myx12345/p/11666961.html 03: 04: 05:https://www.cnblogs.com/myx12345/ ...

  10. Tomcat修改源码,重新编译

    源码和编译的区别:源码不能直接运行,是人读的,而编译后的程序是计算机可以读的.所以它们是不同的语言.