几何——(Gym-102267H)Circle of Polygon

题目

A circumscribed circle of a polygon is the circle that passes through all the vertices of that polygon.
Let’s assume we have a regular polygon, we want to find the area of the circumscribed circle around this polygon. Given the number of vertices and the side length of the polygon, can you find the circle’s area?
在这里插入图片描述
Input
The only line contains 2 integers , V(3≤V≤359) the number of vertices of the polygon and S(1≤S≤1e9)
Output
Find the area of the resulting circumscribed circle.Your answer will be considered correct if its absolute or relative error does not exceed 1e−6.
Namely: let’s assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if |a−b|/max(1,b)≤1e-6.

Example
Input
8 2
Output
21.452136491

Note
The octagon in the picture illustrates the first example.

题意

给出一个多边形的边数和边长,求这个多边形的外接圆面积。

解析

设正N边形的外接圆圆心O,O也是正N边形的中心,圆心与正N边形顶点A的连线OA(也就是圆半径)是正N边形那个顶角的角平分线,而正N边形顶角度数为180-360/N,假设正N边形的边长为L,与A相邻的另一个顶点为B,则等腰三角形OAB的两个底角θ= 90-180/N 半径OA=L/2÷cosθ 。
在这里插入图片描述

正确代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long
const double pi = acos(-1.0);//acos函数的作用是返回输入值所对应的弧度
int main()
{
    double n,l;
    scanf("%lf %lf",&n,&l);
    double x=cos(pi/2-pi/n);
    double s=pi*(l*l)/(4*x*x);
    printf("%f\n",s);
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值