概述
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.
样例输入
1 152973.6 1 -1
样例输出
1 23665
题目来源
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
题目如图所示,给出开始时圆的半径,求构造出的第k个圆的半径。
笛卡尔定理如下:
定义一个圆的曲率
k=±1r
,其中
r
是其半径。
若平面有两两相切,且有
6
个独立切点的四个圆,设其曲率为
k1,k2,k3,k4
(若该圆与其他圆均外切,则曲率取正,否则取负)则其满足性质:
接着,套公式算就可以了。
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=100005, inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ld pi = 3.14159L;
ld ans[15];
int main() {
int cnt = 0,sum=0;
ld l = 0L,r;
int cas,s,i,k;
scanf("%d", &cas);
cin >> r;
l = 1.0L / r ;
r = l;
for (i = 1; i <= 10; i++) {
ans[i] = sqrt(2.0L*((r+r+l)*(r+r+l)-r*r-r*r - l*l));
ans[i] += r + r + l;
// cout << ans[i] << endl;
l = ans[i];
ans[i] = 1.0L / ans[i];
}
while (cas--) {
scanf("%d", &k);
s = floor(ans[k]);
printf("%d ", k);
cout << s << endl;
}
//
system("pause");
return 0;
}
最后
以上就是冷静板凳为你收集整理的Finding the Radius for an Inserted Circle 笛卡尔定理 - 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛的全部内容,希望文章能够帮你解决Finding the Radius for an Inserted Circle 笛卡尔定理 - 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复