爆炸几何之 CCPC网络赛 I - The Designer (笛卡尔定理)
本文版权归BobHuang和博客园共有,不得转载。如想转载,请联系作者,并注明出处。
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
这个是题目,很快就看懂了,而且我有了一堆关系可以用,比如第几个圆,还有些相切的关系
但这个题我肯定是要用题解方法做的,不然精度炸飞
援引自百度百科,百度百科来源于一篇论文(见《笛卡尔定理与一类多圆相切问题》(作者:王永喜、李奋平)。)
这个为什么是成立的呢
可以从最简单的推
设三个圆的半径分别是a,b,c
然后就
这道题和论文中的这个内容相似
把1替换成r,2替换成R就可以对这个图进行求解
有个专业术语叫Pappus chain
有些美妙吧
#include<bits/stdc++.h> using namespace std; const double eps=1e-13; 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=1./k4/k4; for(int i=1; i<=n&&t>eps; i+=2) { ans+=t; if(i+1<=n)ans+=t; double k5=2*(k1+k2+k4)-k3; k3=k4; k4=k5; t=1./k4/k4; } printf("%.5f\n",ans*PI); } return 0; }
本文版权归BobHuang和博客园共有,不得转载。如想转载,请联系作者,并注明出处。
相关文章
- smokeping网络监控
- Transformer 网络
- 分享Python网络爬虫过程中编码和解码的一个库
- J Biosci|分子相互作用网络:机遇、挑战和前景
- 【网络编程开发系列】一种网络编程中的另类内存泄漏(RT-Thread技术论坛优秀文章)
- 解决The HTTP request is not acceptable for the requested resource
- Socket套接字(网络编程万字总结-附代码)
- Qt开源网络库[12]-身份验证
- ORA-26747: The one-to-many transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-26748: The one-to-one transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-32341: The EXPLAIN_MVIEW facility failed to explain the materialized view “string”.”string” ORACLE 报错 故障修复 远程处理
- ORA-38475: The attribute set and the associated ADT are out of sync. ORACLE 报错 故障修复 远程处理
- ORA-46012: The value of the “privilege” element is too long. ORACLE 报错 故障修复 远程处理
- ORA-46015: The value of the “paramDatatype” element is too long. ORACLE 报错 故障修复 远程处理
- ORA-48485: The file exceeds the maximum length [string] ORACLE 报错 故障修复 远程处理
- ORA-13605: The specified task or object string does not exist for the current user. ORACLE 报错 故障修复 远程处理
- Linux网络配置实训:轻松掌握技能(linux网络配置实训)
- Linux网络配置的重要性(linux的网络配置文件)
- The Power of Linux: Unleashing the Potential of OpenSource Software(linux英文)
- Linux架设VPN,掌握安全网络(linuxvpn架设)
- 修复 Ubuntu 中 “E: The package cache file is corrupted, it has the wrong hash”
- Exploring the versatility of Linux: The significance of the var directory(linux系统var)
- 掌控网络:Linux的上网行为管理(linux上网行为管理)