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

【队友代码】

 #include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int maxn=1e4+;
double r[];
int main()
{
int t;
int x;
int k,m;
scanf("%d",&t);
while(t--)
{
memset(r,,sizeof r);
scanf("%d",&x);
printf("%d ",x);
scanf("%d%d",&k,&m);
double s=pi/k;
r[]=1.0*sin(s)/(1.0-sin(s)); double b=-(2.0*((+r[])/tan(s)+r[]));
double a=(1.0/(tan(s)*tan(s)));
double c=*r[]+;
r[]=(-b+sqrt(b*b-4.0*a*c))/(2.0*a); for(int i=;i<=m+;i++)r[i]=(r[i-]*r[i-])*1.0/r[i-]*1.0;
double ans=(*k+*pi)*r[m+];
printf("%.3f %.3f\n",r[m+],ans); }
return ;
}

【计算几何】The Queen’s Super-circular Patio的更多相关文章

  1. POJ 2069 Super Star(计算几何の最小球包含+模拟退火)

    Description During a voyage of the starship Hakodate-maru (see Problem 1406), researchers found stra ...

  2. POJ2546 Circular Area(计算几何)

                                                                                Circular Area            ...

  3. The Queen's Super-circular Patio 求栏杆

    Input The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of da ...

  4. 用开源项目circular progress button实现有进度条的Button

    circular progress button可以让button实现进度条,效果和动画都做的很赞,只是有点小bug.需要注意的是按钮上的文字不能太大,否则会出现错位. 项目的地址:https://g ...

  5. 子类继承父类时JVM报出Error:Implicit super constructor People() is undefined for default constructor. Must define an explicit constructor

    当子类继承父类的时候,若父类没有定义带参的构造方法,则子类可以继承父类的默认构造方法 当父类中定义了带参的构造方法,子类必须显式的调用父类的构造方法 若此时,子类还想调用父类的默认构造方法,必须在父类 ...

  6. 如何在Spring MVC Test中避免”Circular view path” 异常

    1. 问题的现象 比如在webConfig中定义了一个viewResolver public class WebConfig extends WebMvcConfigurerAdapter { //配 ...

  7. [LeetCode] Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  8. Maven Super POM

    Maven super POM defines some properties. Three ways to find it ${M2_HOME}/lib/maven-model-builder-3. ...

  9. java基础 super 子类调用父类

    如果希望在子类中,去调用父类的构造方法,要求在子类的构造函数调用 example如下: package test; /* * 如果希望在子类中,去调用父类的构造方法,要求在子类的构造函数调用 * */ ...

随机推荐

  1. meshing-球体网格划分

    原视频下载地址:https://yunpan.cn/cqwvgQQ2xy3G6  访问密码 a54b

  2. eclipse导入maven项目有红叉及pom.xml出错的问题的解决

    导入我们的项目的时候总会出现很多红叉,看着很难受,其实可以解决的(本人使用方法一解决)解决方法:1.先build project,然后右键项目->maven->update project ...

  3. rand随机函数

    1.rand() rand()函数是使用线性同余法做的,它并不是真的随机数,因为其周期特别长,所以在一定范围内可以看成随机的. rand()函数不需要参数,它将会返回0到RAND_MAX之间的任意的整 ...

  4. 一百四十七:CMS系统之celery实现邮件和短信异步发送

    celery工作原理 celery官方文档:https://docs.celeryproject.org/en/latest/ 安装:pip install celery windows下还需安装ev ...

  5. 123457123456#1#-----com.threeapp.qianShuiTingYX01-----潜水艇跑酷游戏01

    com.threeapp.qianShuiTingYX01-----潜水艇跑酷游戏01

  6. Python简单计算数组元素平均值的方法示例

    Python简单计算数组元素平均值的方法示例 本文实例讲述了Python简单计算数组元素平均值的方法.分享给大家供大家参考,具体如下: Python 环境:Python 2.7.12 x64 IDE ...

  7. Node.js导入jquery.min.js报错

    报错如下: 一看就是路径问题,可是代码中路径看起来貌似没错,如下: 解决方法: 引入方式如下: <script type="text/javascript" src=&quo ...

  8. jsplumb实现流程图

    流程图使用工具汇总 jsPlumb,开源软件,推荐使用,参考学习链接: jsplumb学习笔记.基本概念.中文简易教程 jTopo myflow Go.js JointJS,属于商业软件 mxGrap ...

  9. Python3之高阶函数filter

    Python内建的filter()函数用于过滤序列 和map()一样,filter()也接收一个函数和一个序列.和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是T ...

  10. iOS自定义遮盖

    @interface TGCover : UIView+ (id)cover;+ (id)coverWithTarget:(id)target action:(SEL)action; - (void) ...