题目传送门

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. centos7 安装pip 和 Django过程

    [root@localhost ~]# yum install python-pip 已加载插件:fastestmirror Loading mirror speeds from cached hos ...

  2. pg_dumpall - 抽出一个 PostgreSQL 数据库集群到脚本文件中

    SYNOPSIS pg_dumpall [ option...] DESCRIPTION 描述 pg_dumpall 是一个用于写出("转储")一个数据库集群里的所有 Postgr ...

  3. TensorFlow——CNN卷积神经网络处理Mnist数据集

    CNN卷积神经网络处理Mnist数据集 CNN模型结构: 输入层:Mnist数据集(28*28) 第一层卷积:感受视野5*5,步长为1,卷积核:32个 第一层池化:池化视野2*2,步长为2 第二层卷积 ...

  4. linux--基础知识2

    #超级用户root的家目录是/root ,而普通用户的家目录被存放在/home目录下 cd /目录  切换到指定目录 注意 /  是根目录 linux的一些重要目录 1.bin目录,用来存放常用的可执 ...

  5. Oracle 附加日志(supplemental log)

    参考资料: 1.https://blog.csdn.net/li19236/article/details/41621179

  6. Linux telnet、nc、ping监测状态

    在工作中会遇到网络出现闪断丢包的情况,最终影响业务工常使用.可以业务服务器上发起监测. 1.通过telnet echo  -e  "\n" | telnet localhost 2 ...

  7. springboot通过继承OncePerRequestFilter,在拦截器中@Autowired 为null问题

    springboot2版本以上环境 通过继承OncePerRequestFilter类,在重写doFilterInternal方法实现拦截的具体业务逻辑, 在实现的过程中,需要注入service方法, ...

  8. common pom

    <dependencies> <dependency> <groupId>com.github.pagehelper</groupId> <art ...

  9. Listary安装+破解

    Listary 是 windows 下一个可以快速搜索所有程序,文件,并且可以快速启动程序和打开相应文件的这么一个工具,但这只是它的一个主要功能,还有其功能也是很屌的. 详细的介绍参考:[Listar ...

  10. php array_intersect()函数 语法

    php array_intersect()函数 语法 作用:用于比较两个(或更多个)数组的键值,并返回交集.直线电机生产厂家 语法:array_intersect(array1,array2,arra ...