Everything Has Changed

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 292    Accepted Submission(s): 155
Special Judge

Problem Description
Edward is a worker for Aluminum Cyclic Machinery. His work is operating mechanical arms to cut out designed models. Here is a brief introduction of his work.
Assume the operating plane as a two-dimensional coordinate system. At first, there is a disc with center coordinates (0,0) and radius R. Then, m mechanical arms will cut and erase everything within its area of influence simultaneously, the i-th area of which is a circle with center coordinates (xi,yi) and radius ri (i=1,2,⋯,m). In order to obtain considerable models, it is guaranteed that every two cutting areas have no intersection and no cutting area contains the whole disc.
Your task is to determine the perimeter of the remaining area of the disc excluding internal perimeter.
Here is an illustration of the sample, in which the red curve is counted but the green curve is not.
 
Input
The first line contains one integer T, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains two integers m and R.
The i-th line of the following m lines contains three integers xi,yi and ri, indicating a cutting area.
1≤T≤1000, 1≤m≤100, −1000≤xi,yi≤1000, 1≤R,ri≤1000 (i=1,2,⋯,m).
 
Output
For each test case, print the perimeter of the remaining area in one line. Your answer is considered correct if its absolute or relative error does not exceed 10−6.
Formally, let your answer be a and the jury's answer be b. Your answer is considered correct if |a−b|max(1,|b|)≤10−6.
 
Sample Input
1
4 10
6 3 5
10 -4 3
-2 -4 4
0 9 1
 
Sample Output
81.62198908430238475376
 
Source
 
题意:给你一个圆心位于原点,半径为R的大圆,然后对大圆进行m次操作,每次切去小圆和大圆相交的区域,求切去这些区域后大圆剩余的外部周长
分析:高中几何数学问题。比赛的时候我怎么不自己去想想就给队友做了,明明上午才做过一个类似的要用到余弦定理的题目,自己写B题也写了两个对小时才A出来,导致最后才一个小时才A出这道题。
     两圆相交分情况考虑:
    外切外离内含不会切割大圆不用考虑
    内切完整切割了一部分大圆区域,同时小圆的周长会全部成为大圆的外部周长,所以直接加上小圆的周长
    相交小圆占了大圆一部分区域,大圆会损失一部分弧长,同时会得到小圆的一部分弧长,我们可以通过计算圆心角求出这部分弧长,圆心角可以通过圆心距和两个圆半径求出(这三个距离构成了一个三角形,通过余弦定理求)
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e2+10;
const ll mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll T;
cin >> T;
while( T -- ) {
ll m, R;
cin >> m >> R;
double ans = 2*pi*R;
for( ll i = 0, x, y, r; i < m; i ++ ) {
cin >> x >> y >> r;
double dis = sqrt(x*x+y*y);
if( dis >= r+R ) { //外切外离不考虑
continue;
} else if( dis > fabs(R-r) && dis < R+r ) { //相交
double deg1 = acos((dis*dis+R*R-r*r)/(2.0*dis*R));
double deg2 = acos((dis*dis+r*r-R*R)/(2.0*dis*r));
ans -= deg1*2*R;
ans += deg2*2*r;
} else if( dis == R-r ) { //内切
ans += 2*pi*r;
}
}
printf("%.20lf\n",ans);
}
return 0;
}

  

hdu6354 杭电第五场 Everything Has Changed 计算几何的更多相关文章

  1. hdu6351 Beautiful Now 杭电第五场 暴力枚举

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  2. hdu6373 Pinball 杭电第六场 物理知识

    Pinball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  3. 杭电第四场 hdu6336 Problem E. Matrix from Arrays 打表找规律 矩阵前缀和(模板)

    Problem E. Matrix from Arrays Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 ...

  4. 杭电第六场 hdu6362 oval-and-rectangle 积分求期望

    oval-and-rectangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. 喝奶茶最大值(不能喝自己班级的)2019 Multi-University Training Contest 8--hdu杭电第8场(Roundgod and Milk Tea)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6667 题意: 有 n个班级,每个班级有a个人.b个奶茶,每个班的人不能喝自己的奶茶,只能喝别人班的奶茶 ...

  6. hdu 1290_献给杭电五十周年校庆的礼物

    Description 或许你曾经牢骚满腹或许你依然心怀忧伤或许你近在咫尺或许你我天各一方 对于每一个学子母校 永远航行在生命的海洋 今年是我们杭电建校五十周年,这是一个值得祝福的日子.我们该送给母校 ...

  7. HDU 1290 献给杭电五十周年校庆的礼物(面分割空间 求得到的最大空间数目)

    传送门: 献给杭电五十周年校庆的礼物 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  8. [HDU1290]献给杭电五十周年校庆的礼物

    [HDU1290]献给杭电五十周年校庆的礼物 题目大意: 问\(n(n\le1000)\)个平面能够将一个三维空间分成几部分. 思路: 公式\(\frac{n^3+5n+6}6\). 源代码: #in ...

  9. 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)

    以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...

随机推荐

  1. Git 从master拉取代码创建新分支

    从master拉取新分支并push到远端 开发过程中经常用到从master分支copy一个开发分支: 1.切换到被copy的分支(master),并且从远端拉取最新版本 $git checkout m ...

  2. java 8中新的日期和时间API

    java 8中新的日期和时间API 使用LocalDate和LocalTime LocalDate的实例是一个不可变对象,它只提供了简单的日期,并不含当天的时间信息.另外,它也不附带任何与时区相关的信 ...

  3. Android 属性动画实战

    什么是属性动画? 属性动画可以通过直接更改 View 的属性来实现 View 动画.例如: 通过不断的更改 View 的坐标来实现让 View 移动的效果: 通过不断的更改 View 的背景来实现让 ...

  4. HiveQL DDL 常用QL示例资料

    hive-version2.1.1 DDL操作 Create/Drop/Alter/Use Database 创建数据库 //官方指导 CREATE (DATABASE|SCHEMA) [IF NOT ...

  5. MySQL数据库基本知识(理论总结)

    定义:数据库就是一个文件系统,通过sql语句来获取数据 关系型数据库:关系型数据库存放的是实体时间的关系,在数据库层面来看就是存放的是表和表之间的关联关系 常见的关系型数据库   MySQL    D ...

  6. RocketMQ中PullConsumer的启动源码分析

    通过DefaultMQPullConsumer作为默认实现,这里的启动过程和Producer很相似,但相比复杂一些 [RocketMQ中Producer的启动源码分析] DefaultMQPullCo ...

  7. EMCAscript6随心所记

    es6的支持情况http://kangax.github.io/compat-table/es6/ 1.let命令 基本用法 ES6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变 ...

  8. php安装mongo扩展(linux)

    1.首先下载php的mongodb扩展 从http://pecl.php.net/package/mongodb这个网址下载mongodb的扩展源码包 2.解压安装包 tar zxf mongodb- ...

  9. 【原创】关于DNS不得不说的一些事

    引言 今天我们来聊聊DNS. 所谓域名系统(Domain Name System缩写DNS,Domain Name被译为域名)是因特网的一项核心服务,它作为可以将域名和IP地址相互映射的一个分布式数据 ...

  10. Discuz! ML远程代码执行(CVE-2019-13956)

    Discuz! ML远程代码执行(CVE-2019-13956) 一.漏洞描述 该漏洞存在discuz ml(多国语言版)中,cookie中的language可控并且没有严格过滤,导致可以远程代码执行 ...