The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.

You are given a regular polygon with 2⋅n vertices (it’s convex and has equal sides and equal angles) and all its sides have length 1. Let’s name it as 2n-gon.

Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.

You can rotate 2n-gon and/or the square.

Input
The first line contains a single integer T (1≤T≤200) — the number of test cases.

Next T lines contain descriptions of test cases — one per line. Each line contains single even integer n (2≤n≤200). Don’t forget you need to embed 2n-gon, not an n-gon.

Output
Print T real numbers — one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn’t exceed 10−6.

Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
思路:比第二道题目简单的不是一点半点。主要用到了余弦定理。
代码如下:

#include<bits/stdc++.h>
#define ll long long
#define PI acos(-1.0)
using namespace std;int n;int main()
{int t;scanf("%d",&t);while(t--){scanf("%d",&n);int m=n;n*=2;double z=1.0/(2.0-2.0*cos(PI/(m*1.0)));double y=z+z-2.0*z*cos(((m-2)*1.0/n)*PI);double x=sqrt(y/2.0);x=2.0*x+1.0;printf("%.9lf\n",x);}return 0;
}

努力加油a啊,(o)/~

Simple Polygon Embedding CodeForces - 1354C1(计算几何)相关推荐

  1. Not So Simple Polygon Embedding CodeForces - 1354C2(计算几何)

    The statement of this problem is the same as the statement of problem C1. The only difference is tha ...

  2. Educational Codeforces Round 87 (Rated for Div. 2)C2. Not So Simple Polygon Embedding【几何题】

    题目大意就是求n边形最小外接正方形 被卡了好久:听说是结论题: #include<cstdio> #include<cstdlib> #include<iostream& ...

  3. C1. Simple Polygon Embedding(几何)

    已知边长为 1 ,给出偶数 n,求一个最小正方形将 2*n 边形包含起来的面积 已知有一个正 n 边形,我们可以轻松求出 角度α,为 360/(2*n),因为 n 一定可以被四整除,所以一定有四条边在 ...

  4. Simple polygon

    In geometry, a simple polygon /ˈpɒlɪɡɒn/ is a polygon that does not intersect itself and has no hole ...

  5. matlab 凸包质心算法,求多边形凸包(线性算法)--陈氏凸包算法--Computing the convex hull of a simple polygon(源码)...

    陈氏凸包算法-算法参考:Computing the convex hull of a simple polygon 作者:Chern-Lin Chen 陈氏算法提供了一个线性效率求凸包的算法,本文使用 ...

  6. 线段树扫描线求矩形周长详解

    线段树扫描线求矩形周长详解 原创 wucstdio 最后发布于2018-04-24 16:12:09 阅读数 841 收藏 发布于2018-04-24 16:12:09 版权声明:本文为博主原创文章, ...

  7. 【CodeForces - 340B 】Maximal Area Quadrilateral (计算几何,枚举,有坑)

    题干: Iahub has drawn a set of n points in the cartesian plane which he calls "special points&quo ...

  8. Codeforces Round #198 (Div. 2)A,B题解

    Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...

  9. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

最新文章

  1. 如何理解PacBio的准确度?
  2. 解决 win10 下载文件到某盘 没有权限
  3. Netstat命令(windows下)
  4. vue中使用keepAlive组件缓存遇到的坑
  5. paraView做动画(终极教程)
  6. CentOS6.2 自定义系统调用
  7. C#中PostMessage和SendMessage的参数传递实例
  8. [CTSC2017]吉夫特(思维+巧妙)
  9. JavaScript:Browser 对象
  10. 2017年9月计算机二级c语言,2017年9月计算机二级C语言程序设计练习题
  11. 分布式系统中,权限设计实践
  12. 设计模式C++实现_2_简单工厂模式
  13. 大数据面试-02-大数据工程师面试题
  14. jQuery-实例方法
  15. SqlServer实现split功能
  16. 不确定性原理的前世今生 · 数学篇(完)
  17. java-判断集合中的某个元素的属性是否全部相同
  18. 个人漂浮装置UL安全标准 - 第 5 部分:浮力辅助设备(50 级) - 安全要求 UL 12402-5介绍
  19. edge浏览器被恶意插件劫持,不能删除由组织安装的扩展,提示您的浏览器由您的组织管理
  20. FAT32、NTFS、exFAT的区别

热门文章

  1. WPF的binding
  2. oracle 在线表分析报告,Oracle Statspack分析报告详解(一)
  3. 在哪开启oracle服务器,开启企业殿堂的钥匙 Oracle服务器的安装
  4. 矩阵键盘程序_独立按键与矩阵按键
  5. 整数划分问题的递归算法-c语言,简单的整数划分问题(递归)
  6. 简单页面跳转生命周期(简单清晰)
  7. 引导页 设置只显示一次
  8. 解决SwipeRefreshLayout与Banner滑动冲突
  9. java 基本语法与流程控制_Java基础语法之控制流程
  10. jsp医院管理系统_Thymeleaf+SpringBoot+SpringDataJPA实现的中小医院信息管理系统