zoukankan      html  css  js  c++  java
  • 【计算几何】The Queen’s Super-circular Patio

    The Queen’s Super-circular Patio

    题目描述

    The queen wishes to build a patio paved with of a circular center stone surrounded by circular rings of circular stones. All the stones in a ring will be the same size with the same number of stones in each ring. The stones in the innermost ring will be placed touching (tangent to) the adjacent stones in the
    ring and the central stone. The stones in the other rings will touch the two adjacent stones in the next inner ring and their neighbors in the same ring. The fi gures below depict a patio with one ring of three stones and a patio with 5 rings of 11 stones. The patio is to be surrounded by a fence that goes around the outermost stones and straight between them (the heavier line in the fi gures).
    The queen does not yet know how many stones there will be in each circle nor how many circles of stones there will be. To be prepared for whatever she decides, write a program to calculate the sizes of the stones in each circle and the length of the surrounding fence. The radius of the central stone is to be one queenly foot.

    输入

    The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set should be processed identically and independently.
    Each data set consists of a single line of input. It contains the data set number, K, the number, N (3 ≤ N ≤ 20), of stones in each circle and the number, M (1 ≤ M ≤ 15), of circles of stones around the central stone.

    输出

    For each data set there is a single line of output. It contains the data set number, K, followed by a single space which is then followed by the radius (in queenly feet) of the stones in the outermost ring (to 3 decimal places) which is followed by a single space which is then followed by the length (in queenly feet) of the fence (to 3 decimal places).

    样例输入

    3
    1 3 1
    2 7 3
    3 11 5
    

    样例输出

    1 6.464 79.400
    2 3.834 77.760
    3 2.916 82.481


    【参考博客】

    https://www.cnblogs.com/starve/p/11164586.html

    【队友代码】

     1 #include<bits/stdc++.h>
     2 #include <iostream>
     3 #include <stdio.h>
     4 #include <algorithm>
     5 #include <cmath>
     6 #include <math.h>
     7 #include <cstring>
     8 #include <string>
     9 #include <queue>
    10 #include <deque>
    11 #include <stack>
    12 #include <stdlib.h>
    13 #include <list>
    14 #include <map>
    15 #include <utility>
    16 #include <set>
    17 #include <bitset>
    18 #include <vector>
    19 #define pi acos(-1.0)
    20 #define inf 0x3f3f3f3f
    21 #define linf 0x3f3f3f3f3f3f3f3fLL
    22 #define ms(a,b) memset(a,b,sizeof(a))
    23 typedef long long ll;
    24 const int maxn=1e4+5;
    25 double r[25];
    26 int main()
    27 {
    28     int t;
    29     int x;
    30     int k,m;
    31     scanf("%d",&t);
    32     while(t--)
    33     {
    34         memset(r,0,sizeof r);
    35         scanf("%d",&x);
    36         printf("%d ",x);
    37         scanf("%d%d",&k,&m);
    38         double s=pi/k;
    39         r[2]=1.0*sin(s)/(1.0-sin(s));
    40  
    41         double b=-(2.0*((1+r[2])/tan(s)+r[2]));
    42         double a=(1.0/(tan(s)*tan(s)));
    43         double c=2*r[2]+1;
    44         r[3]=(-b+sqrt(b*b-4.0*a*c))/(2.0*a);
    45  
    46         for(int i=4;i<=m+1;i++)r[i]=(r[i-1]*r[i-1])*1.0/r[i-2]*1.0;
    47         double ans=(2*k+2*pi)*r[m+1];
    48         printf("%.3f %.3f
    ",r[m+1],ans);
    49  
    50     }
    51     return 0;
    52 }
  • 相关阅读:
    作业II
    7.26 tar命令
    7.24
    网络003
    网络002
    网络001
    MySQL基于amoeba读写分离实验
    MYSQL数据库之主从复制及读写分离
    MySQL的主从异步复制实验
    MYSQL数据库扩展 索引与事务与引擎
  • 原文地址:https://www.cnblogs.com/Osea/p/11387278.html
Copyright © 2011-2022 走看看