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 ...
随机推荐
- springboot(十九)使用actuator监控应用【转】【补】
springboot(十九)使用actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的 ...
- 2019.10.17beta
import socket import subprocess import os server = socket.socket() server.bind( ('127.0.0.1',8888) ) ...
- 提取网址的python练习
import urllib, urllib2, cookielib from HTMLParser import HTMLParser import sys reload(sys) sys.setde ...
- Timer和DispatcherTimer简单使用
1. 设定计时器相关属性,使用委托方法处理事件触发 DispatcherTimer dispatcherTimer= new DispatcherTimer(); dispatcherTimer.Ti ...
- python中defaultdict类
回宿舍前翻翻Codeforces的时候发现了一个有趣的代码..其实是我没这么用过 :D 这是一份417B的代码 import sys from collections import defaultdi ...
- Path Sum 深度搜索
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- 设置PHP最长运行时间
通常来说,默认的PHP程序最大运行时间是30s,如果你的程序运行超过这个时间限制,那么会有类似Maximum execution time of 30 seconds exceeded的报错. 有几种 ...
- nodejs启本地服务器
https.js var PORT = 8666;// var http = require('http'); var url=require('url'); var fs=require('fs') ...
- idea 使用优化
1.创建类的模板 /** * Copyright (C), 2015-${YEAR}, XXX有限公司 * FileName: ${NAME} * Author: ${USER} * Date: ${ ...
- Xcode无法退出,报错提示 The document “xxx.h” could not be saved. The file doesn’t exist.
记录一个问题 场景:Xcode编辑一个工程时直接在工程内部修改了某个目录的文件夹名字,而后删除了其下的某 .h.m 文件 之后总是提示上述错误且无法强制退出Xcode,clean等操作基本没用 查找本 ...