D Thanking-Bear magic
题目描述
He first drew a regular polygon of N sides, and the length of each side is a.
He want to get a regular polygon of N sides, and the polygon area is no more than L.
He doesn't want to draw a new regular polygon as it takes too much effort.
So he think a good idea, connect the midpoint of each edge and get a new regular polygon of N sides.
How many operations does it need to get the polygon he want?
输入描述:
The first line of the input is T(1≤ T ≤ 100), which stands for the number of test cases you need to solve.
The first line of each case contains three space-separated integers N, a and L (3 ≤ N ≤ 10, 1 ≤ a ≤ 100, 1 ≤ L ≤ 1000).
输出描述:
For each test case, output a single integer.
输入例子:
1
4 2 3
输出例子:
1
-->
输出
1 思路:弱弱的推了一半天,在大佬的指点之下终于推出了公式;题意是讲若当前多边形的面积大于L就将每条边的中点依次连接构成一个新的多边形 求多少次这种操作之后面积S不大于L;首先已知多边形边长为a,外接圆半径R = a/(2*sin(pi/n)); 面积S = 0.5*n*R^2*sin((2*pi)/n);
然后以此类推求出内接正多边形的边长与内接正多变形的外接圆半径r;内接正多变的边长x = a*cos(pi/n);emmmmm就以此类推下去了吧下面附上代码
#include<iostream>
#include<cmath>
#define pi 3.141592653589793238462643383
using namespace std; int T,n;
double a,L;
int main()
{
ios::sync_with_stdio(false);
cin>>T;
while(T--){
cin>>n>>a>>L;
double R = a/(2.0*sin(pi/n));
double s = 0.5*n*R*R*sin((*pi)/n);
double r;int ans = ;
while(s>L){
ans++;
a = a*cos(pi/n);
r = a/(2.0*sin(pi/n));
s = 0.5*n*r*r*sin((*pi)/n);
}
cout<<ans<<endl;
}
return ;
}
D Thanking-Bear magic的更多相关文章
- Codeforces CF#628 Education 8 F. Bear and Fair Set
F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces CF#628 Education 8 D. Magic Numbers
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces CF#628 Education 8 C. Bear and String Distance
C. Bear and String Distance time limit per test 1 second memory limit per test 256 megabytes input s ...
- [8.3] Magic Index
A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted ar ...
- Python魔术方法-Magic Method
介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...
- 【Codeforces717F】Heroes of Making Magic III 线段树 + 找规律
F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes inpu ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree
Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...
- 一个快速double转int的方法(利用magic number)
代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast&l ...
- Saddest's polar bear Pizza offered new YorkShire home
Saddest:adj,可悲的,悲哀的,polar,两级的,极地额,YorkShire,约克郡 A UK wildlife park has confirmed that it is offering ...
- MAGIC XPA最新版本Magic xpa 2.4c Release Notes
New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...
随机推荐
- Directx11教程(58) 鼠标控制摄像机
原文:Directx11教程(58) 鼠标控制摄像机 本篇教程我们实现鼠标旋转摄像机的操作.主要就是按下鼠标左键的时候,根据鼠标的移动对摄像机进行pitch, raw的组合旋转.具体修改 ...
- github中markdown语言的使用规则
开始使用github就接触了markdown,确实如它的宗旨所言"易读易写",语法简洁明了,功能比纯文本更强,是一种非常适用于网络的书写语言.并且一大优点是兼容HTML,只要不在m ...
- UIScrollView 实践经验
UIScrollView(包括它的子类 UITableView 和 UICollectionView)是 iOS 开发中最常用也是最有意思的 UI 组件,大部分 App 的核心界面都是基于三者之一或三 ...
- PHPCMS快速建站系列之常用标签
<span class="Nmore"><a href="/index.php?m=content&c=index&a=lists&am ...
- LayUI+Echart实现图表
1.首先 定义一个容器存放图表 需要指定这个容器的大小 <div class="layui-card"> <div class="layui-card ...
- Python学习之路15☞socket编程
一 客户端/服务器架构 即C/S架构,包括 1.硬件C/S架构(打印机) 2.软件C/S架构(web服务) C/S架构与socket的关系: 我们学习socket就是为了完成C/S架构的开发 二 os ...
- python HTTP请求过程的两种常见异常
- 重磅课程|《CNCF x Alibaba 云原生技术公开课》正式开讲!
到底什么是“云原生”?云原生与 CNCF.Kubernetes 是什么关系?作为云计算时代的开发者和从业者,我们该如何在“云原生”的技术浪潮中站稳脚跟,将云原生落地.实现个人的自我升级呢? 201 ...
- shell学习(19)- find查找命令
Linux find命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录 ...
- day10-04_多线程常用属性方法
一.需要了解的方法 Thread实例对象的方法 # isAlive(): 判断这个线程是否是存活的 # getName(): 获取线程名 # setName(): 设置线程名 #enumerate() ...