本文版权归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. 什么是OOA/OOD

    Object Oriented Analyzing Object Oriented Design Object Oriented Programming ooa(object oriented ana ...

  2. VUE学习,vue运行环境搭建遇见的小问题

    1.使用vscode来编辑项目,那么首先给它搭一个vue运行的环境,打开集成终端,使用npm install live-server -g安装live-server. problem1:cmd终端分行 ...

  3. Android Studio报错Unable to resolve dependency for ':app@release/compileClasspath':无法引用任何外部依赖的解决办法

    Android Studio 在引用外部依赖时,发现一直无法引用外部依赖.刚开始以为是墙的问题,尝试修改Gradle配置,未解决问题. 最终发现原来是在Android Sudio安装优化配置时,将Gr ...

  4. 怎样配置JDK开发环境

    (1)我们需要配置三个环境变量,分别是JAVA_HOME,CLASSPATH,Path (2)变量名输入:JAVA_HOME,变量值输入:D:\Java\jdk1.8.0_05点击确定. 需要特别注意 ...

  5. 00_HTTP协议介绍

    1. 什么是HTTP协议 协议是指计算机通信网络中两台计算机之间进行通信所必须共同遵守的规定或规则,超文本传输协议(HTTP)是一种通信协议,它允许将超文本标记语言(HTML)文档从Web服务器传送到 ...

  6. Maven添加本地依赖

    在写本文的时候先来说明一下maven依赖的各种范围的意思 compile(编译范围)       compile 是默认的范围:如果没有提供一个范围,那该依赖的范围就是编译范围.编译范围依赖在所有的c ...

  7. python简单爬虫爬取百度百科python词条网页

    目标分析:目标:百度百科python词条相关词条网页 - 标题和简介 入口页:https://baike.baidu.com/item/Python/407313 URL格式: - 词条页面URL:/ ...

  8. Mysql闪回工具之binlog2sql的原理及其使用

    生产上误删数据.误改数据的现象也是时常发生的现象,作为运维这时候就需要出来补锅了,最开始的做法是恢复备份,然后从中找到需要的数据再进行修复,但是这个时间太长了,对于大表少数数据的修复来讲,动作太大,成 ...

  9. VC-基础:MFC单文档程序架构解析

    MFC单文档程序架构解析 这里我以科院杨老师的单文档程序来分析一下MFC单文档的程序架构,纯属个人见解,不当之处烦请指教! 首先我们了解到的是 图(一) theApp 是唯一一个在程序形成的时候就存在 ...

  10. js函数式编程(三)-compose和pointFree

    compose即函数嵌套组合 组合compose在第一篇已经初见端倪,可以感受一下.compose函数的实现用闭包的方法.不完善实现如下: const compose = (f, g) => { ...