zoukankan      html  css  js  c++  java
  • 圆相切半径4园

    Three circles CaC_{a}Ca​​, CbC_{b}Cb​​, and CcC_{c}Cc​​, 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}C1​​ with radius R1R_{1}R1​​ (R1<RR_{1}<RR1​​<R) is then inserted into the blank area bounded by CaC_{a}Ca​​, CbC_{b}Cb​​, and CcC_{c}Cc​​ so that C1C_{1}C1​​ is tangent to the three outer circles, CaC_{a}Ca​​, CbC_{b}Cb​​, and CcC_{c}Cc​​. Now, we keep inserting a number of smaller and smaller circles Ck (2≤k≤N)C_{k} (2 leq k leq N)Ck​​ (2kN) with the corresponding radius RkR_{k}Rk​​ into the blank area bounded by CaC_{a}Ca​​, CcC_{c}Cc​​ and Ck−1C_{k-1}Ck1​​ (2≤k≤N)(2 leq k leq N)(2kN), so that every time when the insertion occurs, the inserted circle CkC_{k}Ck​​ is always tangent to the three outer circles CaC_{a}Ca​​, CcC_{c}Cc​​ and Ck−1C_{k-1}Ck1​​, as shown in Figure 111

    Figure 1.

    (Left) Inserting a smaller circle C1C_{1}C1​​ into a blank area bounded by the circle CaC_{a}Ca​​, CbC_{b}Cb​​ and CcC_{c}Cc​​.

    (Right) An enlarged view of inserting a smaller and smaller circle CkC_{k}Ck​​ into a blank area bounded by CaC_{a}Ca​​, CcC_{c}Cc​​ and Ck−1C_{k-1}Ck1​​ (2≤k≤N2 leq k leq N2kN), so that the inserted circle CkC_{k}Ck​​ is always tangent to the three outer circles, CaC_{a}Ca​​, CcC_{c}Cc​​, and Ck−1C_{k-1}Ck1​​.

    Now, given the parameters RRR and kkk, please write a program to calculate the value of RkR_{k}Rk​​, i.e., the radius of the k−thk-thkth inserted circle. Please note that since the value of RkR_kRk​​ may not be an integer, you only need to report the integer part of RkR_{k}Rk​​. For example, if you find that RkR_{k}Rk​​ = 1259.89981259.89981259.8998 for some kkk, then the answer you should report is 125912591259.

    Another example, if RkR_{k}Rk​​ = 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 10N10. Furthermore, you may assume π=3.14159pi = 3.14159π=3.14159. The range of each parameter is as below:

    1≤k≤N1 leq k leq N1kN, and 104≤R≤10710^{4} leq R leq 10^{7}104​​R107​​.

    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-11 ---------- a constant −1-11 representing the end of the input file.

    Output Format

    Contains lll lines.

    Line 111: kkk RkR_{k}Rk​​ ----------------output for the value of kkk and RkR_{k}Rk​​ at the test case #111, each of which should be separated by a blank.

    …ldots

    Line iii: kkk RkR_{k}Rk​​ ----------------output for kkk and the value of RkR_{k}Rk​​ at the test case # iii, each of which should be separated by a blank.

    Line lll: kkk RkR_{k}Rk​​ ----------------output for kkk and the value ofRkR_{k}Rk​​ 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,floor(ans));
            }
        }
    }
    
    
  • 相关阅读:
    一周心得5:
    一周心得4:
    历史上两个人合作成功的案例:
    对结对编程的理解:
    一周心得3:
    一周心得2:
    有关IT行业模仿案例及自己的评价与解析:
    一周心得:
    不懂的问题:
    自我介绍以及期望与目标:
  • 原文地址:https://www.cnblogs.com/mfys/p/7588695.html
Copyright © 2011-2022 走看看