博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 C Thinking Bear magic
阅读量:5105 次
发布时间:2019-06-13

本文共 1423 字,大约阅读时间需要 4 分钟。

链接:

来源:牛客网
 

题目描述

In order to become a magical girl, Thinking-Bear are learning magic circle.

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

输入

复制

14 2 3

输出

复制

1

 

 

正多边形面积公式为  S=1/2*sin (2*pi/n)*n*R*R;

R = a/(   2*sin(pi/n)  )

然后,就一直更新面积啦,看需要更新几次,就是答案啦。

用公式写,复杂的也没多大啦QWQ

 

#include
#include
#include
using namespace std;const double eps = 1e-6;#define pi acos(-1.0)int main(){ int T,sum=0;; double N,s,a,b,L; cin>>T; while (T--) { sum=0; cin>>N>>a>>L; s=0.5*sin(2*pi/N)*N*( (a/(2*sin(pi/N)) ) * (a/(2*sin(pi/N)) ) ); while (s>L) { a = a * sin( (N-2) * (pi/ (N*2) ) ); s=0.5*sin(2*pi/N)*N*( (a/(2*sin(pi/N)) ) * (a/(2*sin(pi/N)) ) ); //cout<<"s= "<
<

 

转载于:https://www.cnblogs.com/Romantic-Chopin/p/10253158.html

你可能感兴趣的文章
第一个Spring冲刺周期团队进展报告
查看>>
C++函数基础知识
查看>>
红黑树 c++ 实现
查看>>
Android 获取网络链接类型
查看>>
报表服务框架:WEB前端UI
查看>>
5.9UDP客户端服务器-基于OK6410
查看>>
java自学基础、项目实战网站推荐
查看>>
软件包的使用
查看>>
linux中启动与终止lnmp的脚本
查看>>
gdb中信号的处理[转]
查看>>
学习Javascript闭包(Closure)
查看>>
LeetCode【709. 转换成小写字母】
查看>>
如何在Access2007中使用日期类型查询数据
查看>>
Jzoj4757 树上摩托
查看>>
CF992E Nastya and King-Shamans(线段树二分+思维)
查看>>
基于docker的spark-hadoop分布式集群之一: 环境搭建
查看>>
oracle 几个时间函数探究
查看>>
第一个Java Web程序
查看>>
Atomic
查看>>
div 显示滚动条与div显示隐藏的CSS代码
查看>>