The Queen’s Super-circular Patio
时间限制: 1 Sec 内存限制: 128 MB题目描述
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.
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 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.
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://haijeng.github.io/2019/08/13/acm2014-I/
1 #include <bits/stdc++.h>
2 using namespace std;
3 typedef long long ll;
4 const double pi=3.1415926535;
5 int main()
6 {
7 int t;
8 scanf("%d",&t);
9 while(t--)
10 {
11 int k,n,m;
12 scanf("%d%d%d",&k,&n,&m);
13 double dio=pi/double(n);
14 double sinn=sin(dio),coss=cos(dio);
15 double r=sinn/(1.0-sinn);
16 double R=1.0+r;
17 for(int i=2; i<=m; ++i)
18 {
19 R=(R*coss+r*sinn+sqrt(r*r+2*r*R*coss*sinn))/(coss*coss);
20 r=R*sinn;
21 }
22 printf("%d %.3f %.3f\n",k,r,2.0*r*(double(n)+pi));
23 }
24 return 0;
25 }
26 /*
27 3
28 1 3 1
29 2 7 3
30 3 11 5
31 */
本文介绍了一项关于设计环形露台的编程挑战,露台由中央圆形石头和围绕它的多个圆环组成,每个圆环包含相同数量的圆形石头。文章提供了问题描述、输入输出格式、样例输入输出及参考代码,旨在帮助读者理解如何通过编程计算不同环数和石头数时露台的尺寸。

被折叠的 条评论
为什么被折叠?



