HDU 6158 The Designer 笛卡尔定理+韦达定理 2017ccpc网络赛
来源:互联网 发布:linux添加中文输入法 编辑:程序博客网 时间:2024/06/10 03:03
The Designer
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1198 Accepted Submission(s): 233
Problem Description
Nowadays, little haha 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 Figure1
At first,haha 's teacher gives him two big 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 Figure1 .
Each small circles are added by the following principles.
* you should add the small circles in the order likeFigure1 .
* every time you add a small circle, you should make sure that it is tangented with the other circles (2 or 3 circles) likeFigure1 .
The teacher wants to know the total amount of pigment he would use when he creates his master piece.haha doesn't know how to answer the question, so he comes to you.
Task
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.
At first,
Each small circles are added by the following principles.
* you should add the small circles in the order like
* every time you add a small circle, you should make sure that it is tangented with the other circles (2 or 3 circles) like
The teacher wants to know the total amount of pigment he would use when he creates his master piece.
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.
Input
The first line contains a integer t(1≤t≤1200) , which means the number of the test cases. For each test case, the first line insist of two integers R1 and R2 separated by a space (1≤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 N (1≤N≤10 000 000 ), which is the number of small circles the teacher want to add.
Output
For 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).
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
25 414 51
Sample Output
3.141593.14159
Source
2017中国大学生程序设计竞赛 - 网络选拔赛
思路:笛卡尔定理https://baike.baidu.com/item/%E7%AC%9B%E5%8D%A1%E5%B0%94%E5%AE%9A%E7%90%86/20406483?fr=aladdin
先用笛卡尔定理列出方程求出面积,再用韦达定理递推。因为当n很大的时候,圆的面积就会无限小,答案要求保留5位小数,所以当推到一定次数就可以跳出了。
#include<iostreaM>#include<stdio.h>#include<math.h>#include<algorithm>#define PI acos(-1.0)using namespace std;int main(){ double r3,r4; int n,m; scanf("%d",&n); while(n--) { scanf("%lf%lf",&r3,&r4); if(r3>r4) swap(r3,r4); scanf("%d",&m); double r1,r2; r2=r4-r3; double A=(1.0/r2+1.0/r3-1.0/r4); r1=1.0/A; //printf("%.5lf\n",r1); double sum=PI*r2*r2; double ans=0; for(int i=1;i<m;i+=2) { if(r1*r1<1e-15) break; if(i==m-1) { ans+=PI*r1*r1; } else { ans+=2*PI*r1*r1; //printf("%.5lf\n",ans); double t=1.0/r2; r2=r1; A=(1.0/r2+1.0/r3-1.0/r4); r1=1.0/(2.0*A-t); //printf("%.5lf\n",r1); } } printf("%.5lf\n",ans+sum); }}
阅读全文
0 0
- HDU 6158 The Designer 笛卡尔定理+韦达定理 2017ccpc网络赛
- HDU 6158 The Designer(笛卡尔定理+韦达定理)
- HDU 6158 The Designer(笛卡尔定理)
- HDU 6158 The Designer【计算几何+笛卡尔定理+韦达定理】
- hdu 6158 The Designer && 计蒜客 Finding the Radius for an Inserted Circle 笛卡尔定理应用+韦达定理
- HDU 6158 计算几何 笛卡尔定理 + 韦达定理
- HDU 6158 (计算几何+笛卡尔定理+韦达定理)
- hdu 6158 The Designer && 计蒜客 Finding the Radius for an Inserted Circle 笛卡尔定理应用
- hdu5832 CCPC 网络赛 同余求模定理
- 2017CCPC 网络选拔赛1003 Ramsey定理
- 2017 CCPC网络赛 1009 The Designer(未完待续)
- hdu6152-CCPC网络赛&思维&拉姆齐定理-Friend-Graph
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: G. Finding the Radius for an Inserted Circle(笛卡尔定理)
- hdu6152 Friend-Graph (2017 ccpc 网络赛 (暴力 + 一个神奇的定理)
- 2017CCPC网络赛 Friend-Graph(暴力、拉姆齐(Ramsey)定理)
- HDU 2092 韦达定理
- Finding the Radius for an Inserted Circle 笛卡尔定理
- HDU 1812 - Count the Tetris【Polya定理】
- warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
- vue中如何不通过路由直接获取url中的参数
- 宽度变小,菜单项减少,并添加到更多项里
- hdu2665主席树(可持久化线段树)
- java解析xml转为Map
- HDU 6158 The Designer 笛卡尔定理+韦达定理 2017ccpc网络赛
- git
- PHP 装饰器模式
- 周志华《机器学习》笔记:第5章 神经网络
- Watering Grass UVA
- GIT常用命令
- 使用for update卡住锁表的解决办法(转)
- Java 框架之Hibernate (二、Hibernate简单的增删改及关系的简单分析)
- Xlist