2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 D-Thinking-Bear magic

4 篇文章 0 订阅

链接:https://www.nowcoder.com/acm/contest/163/D
来源:牛客网
 

题目描述

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

输入

1
4 2 3

输出

1

分析:题意是给出一个正多边形和多边形的每一条边的边长,然后给出一个面积,求每次在正多边形的的边取中点,然后连接各个中点,形成一个新的正多边形,问经过几次这次这样的操作后能使面积小于L。这是一道很简单的计算几何题,只要每次求出边心距然后求出多边形面积大小即可。

ac代码:

#include<bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int t, n, a, l;

int main(){
	scanf("%d", &t);
	int Case = 1;
	while(t--){
		scanf("%d%d%d", &n, &a, &l);
		double du = 1.0*360/n;
		double len = (1.0*a/2)/sin((du/2)*(PI/180));
		int ans = 0;
		double are = (1.0/2)*sin(du*(PI/180))*len*len*n;
		while(are > l){
			len = 1.0*cos((du/2)*(PI/180))*len;
			are = (1.0/2)*sin(du*(PI/180))*len*len*n;
			ans++;
		}
		printf("%d\n", ans);
	}
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值