本文版权归BobHuang和博客园共有,不得转载。如想转载,请联系作者,并注明出处。

 
Nowadays, little hahahaha got a problem from his teacher.His teacher wants to design a big logo for the campus with some circles tangent with each other. And now, here comes the problem. The teacher want to draw the logo on a big plane. You could see the example of the graph in the Figure1Figure1

At first, hahahaha's teacher gives him two bigbig circles, which are tangent with each other. And, then, he wants to add more small circles in the area where is outside of the small circle, but on the other hand, inside the bigger one (you may understand this easily if you look carefully at the Figure1Figure1.

Each small circles are added by the following principles. 
* you should add the small circles in the order like Figure1Figure1. 
* every time you add a small circle, you should make sure that it is tangented with the other circles (2 or 3 circles) like Figure1Figure1. 
     
The teacher wants to know the total amount of pigment he would use when he creates his master piece.hahahaha doesn't know how to answer the question, so he comes to you.

TaskTask 
The teacher would give you the number of small circles he want to add in the figure. You are supposed to write a program to calculate the total area of all the small circles. 

InputThe first line contains a integer t(1≤t≤1200)t(1≤t≤1200), which means the number of the test cases. For each test case, the first line insist of two integers R1R1 and R2R2 separated by a space (1≤R≤1001≤R≤100), which are the radius of the two big circles. You could assume that the two circles are internally tangented. The second line have a simple integer NN (1≤N≤10 000 0001≤N≤10 000 000), which is the number of small circles the teacher want to add. 
OutputFor each test case: 
Contains a number in a single line, which shows the total area of the small circles. You should out put your answer with exactly 5 digits after the decimal point (NO SPJ). 
Sample Input

2
5 4
1
4 5
1

Sample Output

3.14159
3.14159

这个是题目,很快就看懂了,而且我有了一堆关系可以用,比如第几个圆,还有些相切的关系

但这个题我肯定是要用题解方法做的,不然精度炸飞

援引自百度百科,百度百科来源于一篇论文(见《笛卡尔定理与一类多圆相切问题》(作者:王永喜、李奋平)。)

若平面上四个半径为r1、r2、r3、r4的圆两两相切于不同点,则其半径满足以下结论:
(1)若四圆两两外切,则

  

(2)若半径为r1、r2、r3的圆内切于半径为r4的圆中,则

  

笛卡尔定理在三维坐标系中也有类似的结论:若五个球的半径是ri(1,2,...,5),满足任意一个球与其他四个球外切,则

  


这个为什么是成立的呢

可以从最简单的推

设三个圆的半径分别是a,b,c

然后就

这道题和论文中的这个内容相似

把1替换成r,2替换成R就可以对这个图进行求解

有个专业术语叫Pappus chain

有些美妙吧

#include<bits/stdc++.h>
using namespace std;
const double eps=1e-;
const double PI=acos(-1.0);
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int R,r,n;
scanf("%d%d%d",&R,&r,&n);
if(R<r)swap(R,r);
double k1=-1.0/R,k2=1.0/r,k3=1.0/(R-r);
double k4=k1+k2+k3;
double ans=(R-r)*(R-r);
n--;
double t=./k4/k4;
for(int i=; i<=n&&t>eps; i+=)
{
ans+=t;
if(i+<=n)ans+=t;
double k5=*(k1+k2+k4)-k3;
k3=k4;
k4=k5;
t=./k4/k4;
}
printf("%.5f\n",ans*PI);
}
return ;
}

本文版权归BobHuang和博客园共有,不得转载。如想转载,请联系作者,并注明出处。

爆炸几何之 CCPC网络赛 I - The Designer (笛卡尔定理)的更多相关文章

  1. 【2018 CCPC网络赛】1003 - 费马小定理

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=6440 这题主要是理解题意: 题意:定义一个加法和乘法,使得 (m+n)p = mp+np; 其中给定 ...

  2. 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

    // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以 ...

  3. (四面体)CCPC网络赛 HDU5839 Special Tetrahedron

    CCPC网络赛 HDU5839 Special Tetrahedron 题意:n个点,选四个出来组成四面体,要符合四面体至少四条边相等,若四条边相等则剩下两条边不相邻,求个数 思路:枚举四面体上一条线 ...

  4. 2018 CCPC网络赛

    2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...

  5. ccpc 网络赛 hdu 6155

    # ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...

  6. 2018年 CCPC 网络赛 赛后总结

    历程:由于只是网络赛,所以今天就三开了.一开始的看题我看了d题,zz和jsw从头尾看起来,发现c题似乎可做,和费马大定理有关,于是和zz一起马上找如何计算勾股数的方法,比较慢的A掉了,而jsw此时看了 ...

  7. 2019杭电多校&CCPC网络赛&大一总结

    多校结束了, 网络赛结束了.发现自己还是太菜了,多校基本就是爆零和签到徘徊,第一次打这种高强度的比赛, 全英文,知识点又很广,充分暴露了自己菜的事实,发现数学还是很重要的.还是要多刷题,少玩游戏. 网 ...

  8. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  9. hdu 5833 Zhu and 772002 ccpc网络赛 高斯消元法

    传送门:hdu 5833 Zhu and 772002 题意:给n个数,每个数的素数因子不大于2000,让你从其中选则大于等于1个数相乘之后的结果为完全平方数 思路: 小于等于2000的素数一共也只有 ...

随机推荐

  1. 终于 Vue.js 成为世界一流的框架

    终于 Vue.js 成为世界一流的框架 随着美团开源基于 Vue.js 的微信小程序框架 mpvue, Vue.js 在微信小程序端的能力被补齐,于是 Vue.js 成为了一个唯一能在 Web, H5 ...

  2. 事件冒泡之cancelBubble和stoppropagation的区别

    事实上stoppropagation和cancelBubble的作用是一样的,都是用来阻止浏览器默认的事件冒泡行为. 不同之处在于stoppropagation属于W3C标准,试用于Firefox等浏 ...

  3. promise从易到难

    Chapter 1 // 需求:你要封装一个方法,我给你一个要读取文件的路径,你这个方法能帮我读取文件,并把内容返回给我 const fs = require('fs') const path = r ...

  4. 洛谷 P2910 [USACO08OPEN]寻宝之路Clear And Present Danger

    题目描述 Farmer John is on a boat seeking fabled treasure on one of the N (1 <= N <= 100) islands ...

  5. LintCode 30插入区间

    问题 给出一个无重叠的按照区间起始端点排序的区间列表. 在列表中插入一个新的区间,你要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间). 样例 插入区间[2, 5] 到 [[1,2], ...

  6. Maven归纳

      一.常用功能 1.Maven的中央仓库 https://mvnrepository.com/ 2.添加jar包依赖 1.首先点击pom.xml,然后点击弹出页面中的Dependencies选项,接 ...

  7. URL URI URN的区别

    下面这张图可以完美的解释他们三者之间的关系 URI包含URL和URN Uniform Resource Identifier :统一资源标志符,用于标识某一互联网资源 Uniform Resoutce ...

  8. python:lambda、filter、map、reduce

    lambda 为关键字.filter,map,reduce为内置函数. lambda:实现python中单行最小函数. g = lambda x: x * 2 #相当于 def g(x): retur ...

  9. js获取当前日期、前一天、后一天的日期的例子

    <script> function addByTransDate(dateParameter, num) { var translateDate = "", dateS ...

  10. MAC进入文件夹快捷键

    common + O common+up common+Down shift + common +G