2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: G. Finding the Radius for an Inserted Circle(笛卡尔定理)
来源:互联网 发布:c语言visit函数 编辑:程序博客网 时间:2024/05/20 09:25
Three circles Ca, Cb, and Cc, all with radius R and tangent to each other, are located in two-dimensional space as shown in Figure 1. A smaller circle C1 with radius R1 (R1<R) is then inserted into the blank area bounded by Ca, Cb, and Cc so that C1 is tangent to the three outer circles, Ca, Cb, and Cc. Now, we keep inserting a number of smaller and smaller circles Ck (2≤k≤N) with the corresponding radius Rk into the blank area bounded by Ca, Cc and Ck−1 (2≤k≤N), so that every time when the insertion occurs, the inserted circle Ck is always tangent to the three outer circles Ca, Cc and Ck−1, as shown in Figure 1
Figure 1.
(Left) Inserting a smaller circle C1 into a blank area bounded by the circle Ca, Cb and Cc.
(Right) An enlarged view of inserting a smaller and smaller circle Ck into a blank area bounded by Ca, Cc and Ck−1 (2≤k≤N), so that the inserted circle Ck is always tangent to the three outer circles, Ca, Cc, and Ck−1.
Now, given the parameters R and k, please write a program to calculate the value of Rk, i.e., the radius of the k−th inserted circle. Please note that since the value of Rk may not be an integer, you only need to report the integer part of Rk. For example, if you find that Rk = 1259.8998 for some k, then the answer you should report is 1259.
Another example, if Rk = 39.1029 for some k, then the answer you should report is 39.
Assume that the total number of the inserted circles is no more than 10, i.e., N≤10. Furthermore, you may assume π=3.14159. The range of each parameter is as below:
1≤k≤N, and 104≤R≤107.
Input Format
Contains l+3 lines.
Line 1: l ----------------- the number of test cases, l is an integer.
Line 2: R ---------------- R is a an integer followed by a decimal point,then followed by a digit.
Line 3: k ---------------- test case #1, k is an integer.
…
Line i+2: k ----------------- test case # i.
…
Line l+2: k ------------ test case #l.
Line l+3: −1 ---------- a constant −1 representing the end of the input file.
Output Format
Contains l lines.
Line 1: k Rk ----------------output for the value of k and Rk at the test case #1, each of which should be separated by a blank.
…
Line i: k Rk ----------------output for k and the value of Rk at the test case # i, each of which should be separated by a blank.
Line l: k Rk ----------------output for k and the value ofRk at the test case # l, each of which should be separated by a blank.
样例输入
1152973.61-1
样例输出
1 23665
(1)笛卡尔定理
定义一个圆的曲率
若平面有两两相切,且有
根据这个定理,我们就可以类似迭代的方式,不断往后递推求解。
#include<bits/stdc++.h>using namespace std;const double PI=3.14159;int main(){ int T,n; double R; while(scanf("%d",&T)!=EOF&&T!=-1) { scanf("%lf",&R); while(T--) { scanf("%d",&n); double k1=1/R,k2=1/R,k3=1/R; double ans; for(int i=0;i<n;i++) { double B=-2*(k1+k2+k3); double C=-(k1+k2+k3)*(k1+k2+k3)+2*(k1*k1+k2*k2+k3*k3); double D=B*B-4*C; double k4=max((-B-sqrt(D))/2,(-B+sqrt(D))/2); ans=1/k4; k3=k4; } printf("%d %0.lf\n",n,floor(ans)); } } return 0;}
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: G. Finding the Radius for an Inserted Circle(笛卡尔定理)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle
- Finding the Radius for an Inserted Circle--2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- Finding the Radius for an Inserted Circle 公式/几何 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 G. Finding the Radius for an Inserted Circle(计算几何,二分)
- 2017 ACM-ICPC南宁网络赛: G. Finding the Radius for an Inserted Circle
- Finding the Radius for an Inserted Circle 笛卡尔定理
- hdu 6158 The Designer && 计蒜客 Finding the Radius for an Inserted Circle 笛卡尔定理应用
- hdu 6158 The Designer && 计蒜客 Finding the Radius for an Inserted Circle 笛卡尔定理应用+韦达定理
- ???Finding the Radius for an Inserted Circle
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛:The Heaviest Non-decreasing Subsequence Problem
- ACM 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 B. Train Seats Reservation
- 空白窗口的创建(MSDN版的空项目)
- iphone苹果手机无法安装迅雷
- 关键字-嵌入式
- 75. Sort Colors(第三周)
- 笔试题整理
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛: G. Finding the Radius for an Inserted Circle(笛卡尔定理)
- 数据库概念及常用关系型数据库
- android设计实现窗体启动时,显示一个水平进度条,当进行完成后,隐藏该进度条,并显示一张图片
- ES6--let
- pythn 冒泡排序
- java调用tensorflow
- Paint的基本使用
- windows,64位下,Python中安装numpy、matplotlib和scipy
- mongodb安装