Three circles CaC_{a}C?a??, CbC_{b}C?b??, and CcC_{c}C?c??, all with radius RRR and tangent to each other, are located in two-dimensional space as shown in Figure 111. A smaller circle C1C_{1}C?1?? with radius R1R_{1}R?1?? (R1<RR_{1}<RR?1??<R) is then inserted into the blank area bounded by CaC_{a}C?a??, CbC_{b}C?b??, and CcC_{c}C?c?? so that C1C_{1}C?1?? is tangent to the three outer circles, CaC_{a}C?a??, CbC_{b}C?b??, and CcC_{c}C?c??. Now, we keep inserting a number of smaller and smaller circles Ck (2≤k≤N)C_{k}\ (2 \leq k \leq N)C?k?? (2≤k≤N) with the corresponding radius RkR_{k}R?k?? into the blank area bounded by CaC_{a}C?a??, CcC_{c}C?c?? and Ck?1C_{k-1}C?k?1?? (2≤k≤N)(2 \leq k \leq N)(2≤k≤N), so that every time when the insertion occurs, the inserted circle CkC_{k}C?k?? is always tangent to the three outer circles CaC_{a}C?a??, CcC_{c}C?c?? and Ck?1C_{k-1}C?k?1??, as shown in Figure 111
Figure 1.
(Left) Inserting a smaller circle C1C_{1}C?1?? into a blank area bounded by the circle CaC_{a}C?a??, CbC_{b}C?b?? and CcC_{c}C?c??.
(Right) An enlarged view of inserting a smaller and smaller circle CkC_{k}C?k?? into a blank area bounded by CaC_{a}C?a??, CcC_{c}C?c?? and Ck?1C_{k-1}C?k?1?? (2≤k≤N2 \leq k \leq N2≤k≤N), so that the inserted circle CkC_{k}C?k?? is always tangent to the three outer circles, CaC_{a}C?a??, CcC_{c}C?c??, and Ck?1C_{k-1}C?k?1??.
Now, given the parameters RRR and kkk, please write a program to calculate the value of RkR_{k}R?k??, i.e., the radius of the k?thk-thk?th inserted circle. Please note that since the value of RkR_kR?k?? may not be an integer, you only need to report the integer part of RkR_{k}R?k??. For example, if you find that RkR_{k}R?k?? = 1259.89981259.89981259.8998 for some kkk, then the answer you should report is 125912591259.
Another example, if RkR_{k}R?k?? = 39.102939.102939.1029 for some kkk, then the answer you should report is 393939.
Assume that the total number of the inserted circles is no more than 101010, i.e., N≤10N \leq 10N≤10. Furthermore, you may assume π=3.14159\pi = 3.14159π=3.14159. The range of each parameter is as below:
1≤k≤N1 \leq k \leq N1≤k≤N, and 104≤R≤10710^{4} \leq R \leq 10^{7}10?4??≤R≤10?7??.
Input Format
Contains l+3l + 3l+3 lines.
Line 111: lll ----------------- the number of test cases, lll is an integer.
Line 222: RRR ---------------- RRR is a an integer followed by a decimal point,then followed by a digit.
Line 333: kkk ---------------- test case #111, kkk is an integer.
…\ldots…
Line i+2i+2i+2: kkk ----------------- test case # iii.
…\ldots…
Line l+2l +2l+2: kkk ------------ test case #lll.
Line l+3l + 3l+3: ?1-1?1 ---------- a constant ?1-1?1 representing the end of the input file.
Output Format
Contains lll lines.
Line 111: kkk RkR_{k}R?k?? ----------------output for the value of kkk and RkR_{k}R?k?? at the test case #111, each of which should be separated by a blank.
…\ldots…
Line iii: kkk RkR_{k}R?k?? ----------------output for kkk and the value of RkR_{k}R?k?? at the test case # iii, each of which should be separated by a blank.
Line lll: kkk RkR_{k}R?k?? ----------------output for kkk and the value ofRkR_{k}R?k?? at the test case # lll, each of which should be separated by a blank.
样例输入
1 152973.6 1 -1
样例输出
1 23665
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int main(){ int T,n; double R; while(scanf("%d",&T),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=(-B+sqrt(D))/2; ans=1/k4; k3=k4; } printf("%d %d\n",n,floor(ans)); } } }