hdu5858 Hard problem(求两圆相交面积)
题目传送门
Hard problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1066 Accepted Submission(s): 622
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.
1
#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(求两圆相交面积)的更多相关文章
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
题目链接: POJ:http://poj.org/problem? id=2546 ZOJ:problemId=597" target="_blank">http: ...
- 求两圆相交部分面积(C++)
已知两圆圆心坐标和半径,求相交部分面积: #include <iostream> using namespace std; #include<cmath> #include&l ...
- hdu 5120 (求两圆相交的面积
题意:告诉你两个圆环,求圆环相交的面积. /* gyt Live up to every day */ #include<cstdio> #include<cmath> #in ...
- poj2546Circular Area(两圆相交面积)
链接 画图推公式 这两种情况 都可用一种公式算出来 就是两圆都求出圆心角 求出扇形的面积减掉三角形面积 #include <iostream> using namespace std; # ...
- [hdu 3264] Open-air shopping malls(二分+两圆相交面积)
题目大意是:先给你一些圆,你可以任选这些圆中的一个圆点作圆,这个圆的要求是:你画完以后.这个圆要可以覆盖之前给出的每一个圆一半以上的面积,即覆盖1/2以上每一个圆的面积. 比如例子数据,选左边还是选右 ...
- hdu 3264 Open-air shopping malls(圆相交面积+二分)
Open-air shopping malls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- poj 2546(两圆公共面积)
Circular Area Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5682 Accepted: 2225 Des ...
- 两圆相交求面积 hdu5120
转载 两圆相交分如下集中情况:相离.相切.相交.包含. 设两圆圆心分别是O1和O2,半径分别是r1和r2,设d为两圆心距离.又因为两圆有大有小,我们设较小的圆是O1. 相离相切的面积为零,代码如下: ...
- HDU 3467 (求五个圆相交面积) Song of the Siren
还没开始写题解我就已经内牛满面了,从晚饭搞到现在,WA得我都快哭了呢 题意: 在DotA中,你现在1V5,但是你的英雄有一个半径为r的眩晕技能,已知敌方五个英雄的坐标,问能否将该技能投放到一个合适的位 ...
随机推荐
- 基于socket实现大文件上传
import socket 1.客户端: 操作流程: 先拿到文件--->获取文件大小---->创建字典 1.制作表头 header 如何得到 他是一个二进制字符串 序列化得到 字典字符串 ...
- 2019-4-21-Roslyn-通过-NuGet-库修改应用程序入口函数
title author date CreateTime categories Roslyn 通过 NuGet 库修改应用程序入口函数 lindexi 2019-4-21 17:37:1 +0800 ...
- 2019-3-1-C#-json-转-xml-字符串
title author date CreateTime categories C# json 转 xml 字符串 lindexi 2019-03-01 09:20:24 +0800 2019-1-1 ...
- 不想用ubuntu了,换个系统manjaro - change
# 下载 https://mirrors.tuna.tsinghua.edu.cn/osdn/storage/g/m/ma/manjaro/xfce/ # usb启动盘 rufus # 中文字体 pa ...
- 结合pychrom与selenium实现页面自动登录
缘起 一直在浏览器里用Katalon插件录制一些常用的流程,以减少重复操作,也就自然而然想自己搞搞自动化测试,但无奈登录一关跨不过去,就无法串起来.(不想让开发添加万能验证码的功能)首先想到的是识别验 ...
- Ansible笔记(7)---常用模块之系统类模块(cron、service)
一.cron模块 1.1作用: cron 模块可以帮助我们管理远程主机中的计划任务,功能相当于 crontab 命令. 在了解cron模块的参数之前,先写出一些计划任务的示例: # 示例1,每天的1点 ...
- windows openssh安装
下载地址:https://github.com/PowerShell/Win32-OpenSSH/releases 解压好后打开目录,执行以下命令: powershell.exe -Execution ...
- Java文件处理之FileReader可输出中文字符
import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public ...
- Dubbo学习-5-监控中心simpleMonitor搭建
之前已经下载好的dubbo-admin-master源码中,有dubbo-monitor-simple工程,同理,使用maven命令打包成一个可执行的jar包: 1.进入dubbo-monitor-s ...
- php array_splice()函数 语法
php array_splice()函数 语法 作用:从数组中移除选定的元素,并用新元素取代它.dd马达价格 语法:array_splice(array,start,length,array) 参数: ...