Forever 0.5

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Given an integer N, your task is to judge whether there exist N points in the plane such that satisfy the following conditions:

1. The distance between any two points is no greater than 1.0.

2. The distance between any point and the origin (0,0) is no greater than 1.0.

3. There are exactly N pairs of the points that their distance is exactly 1.0.

4. The area of the convex hull constituted by these N points is no less than 0.5.

5. The area of the convex hull constituted by these N points is no greater than 0.75.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each contains an integer N described above.

1 <= T <= 100, 1 <= N <= 100

Output

For each case, output “Yes” if this kind of set of points exists, then output N lines described these N points with its coordinate. Make true that each coordinate of your output should be a real number with AT MOST 6 digits after decimal point.

Your answer will be accepted if your absolute error for each number is no more than 10-4.

Otherwise just output “No”.

See the sample input and output for more details.

Sample Input

3
2
3
5

Sample Output

No
No
Yes
0.000000 0.525731
-0.500000 0.162460
-0.309017 -0.425325
0.309017 -0.425325
0.500000 0.162460

Hint

This problem is special judge.

题意:找n个点满足上述五个条件。

题解:n=1和n=2的时候不能构成多边形输出No,n=3的时候最大是边长为1的等边三角形,面积为4分之根号3小于0.5不符合条件输出No。当n=4的时候,在等边三角形的一个顶点的高的方向加一个点,距离该顶点的距离为1即可满足五个条件,如图所示。

AC=AB=BC=BD=1。多边形外侧是一个以(0,0)为圆心半径为1的圆。

当n>=5时,在BC弧上加点即可,Smax=S扇形ABC+S三角形ACD=pi/6+1*(1-sqrt(3)/2)/2=0.59058。符合条件。

角bac是60度也就是pi/3,新加入的点的弧度f为pi/3-0.01*(n-4)即可,n最大100,最多加入96个点不会溢出。

新加入点的横坐标就是cos(f),纵坐标就是sin(f)。用y=sqrt(1-x*x)算也行。

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define pi 3.1415926535897931
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
if(n<=)
{
printf("No\n");
}
else
{
printf("Yes\n"); //开始的时候忘了输出Yes错了三遍
double a=sqrt()/2.0;
printf("0 0\n");
printf("1 0\n");
printf("0.5 %.6lf\n",a);
printf("0.5 %.6lf\n",a-);
double b=pi/3.0;
for(int i=;i<n-;i++)
{
b=b-0.01;
printf("%.6lf %.6lf\n",cos(b),sin(b));
}
}
}
return ;
}

FZU 2140 Forever 0.5 (几何构造)的更多相关文章

  1. FZU 2140 Forever 0.5(找规律,几何)

    Problem 2140 Forever 0.5 Accept: 371 Submit: 1307 Special Judge Time Limit: 1000 mSec Memory Limit : ...

  2. FZU 2140 Forever 0.5

     Problem 2140 Forever 0.5 Accept: 36    Submit: 113    Special JudgeTime Limit: 1000 mSec    Memory ...

  3. fzu Problem 2140 Forever 0.5(推理构造)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...

  4. ACM学习历程—FZU 2140 Forever 0.5(计算几何 && 构造)

    Description   Given an integer N, your task is to judge whether there exist N points in the plane su ...

  5. FZU 2140 Forever 0.5(将圆离散化)

    主要就是将圆离散化,剩下的都好办 #include<iostream> #include<cstdio> #include<cstring> #include< ...

  6. spring 3.0 应用springmvc 构造RESTful URL 详细讲解

    在线springmvc_rest demo 由于下一版本的rapid-framwork需要集成spring RESTful URL,所以研究了一下怎么搭建. 并碰到了一下问题. springmvc 3 ...

  7. fzu 2035 Axial symmetry(枚举+几何)

    题目链接:fzu 2035 Axial symmetry 题目大意:给出n个点,表示n边形的n个顶点,判断该n边形是否为轴对称图形.(给出点按照图形的顺时针或逆时针给出. 解题思路:将相邻两个点的中点 ...

  8. swift3.0 基础练习-构造对象并按要求进行排序(struct)

    struct练手 构造10个学生(要求有学生的姓名.数学成绩.英语成绩),按照学生英语和数学平均分的成绩从小到大输出学生的姓名.数学成绩.英语成绩及平均分 创建一个学生构造体,包含 姓名 name 数 ...

  9. SDL2.0的几何图行绘画

    SDL2.0的几何图形绘画 通过SDL_Window.SDL_Renderer.SDL_Texture三者实现了简单的几何图形绘画. 包括了SDL_RenderDrawPoint.SDL_Render ...

随机推荐

  1. BZOJ-1189 紧急疏散evacuate BFS预处理+最大流+二分判定+神建模!!

    绝世污题,垃圾题,浪费我一整天青春! 1189: [HNOI2007]紧急疏散evacuate Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1262 ...

  2. DLUTOJ 1142 高中的公式

    传送门 Time Limit: 1 Sec  Memory Limit: 128 MB Description 据说...高中学习了好多公式.所以...萌学长不知道该用什么公式来解决下面这个问题.对于 ...

  3. c# 闭包 小例

    class Program { static void fnnn() { string[] k = new string[] { "x", "y", " ...

  4. 统计网站访问量,以GD2库图像形式输出

    index.php页面<?php session_start(); if($_SESSION[temp]==""){ //判断$_SESSION[temp]=="& ...

  5. Linux中vi编辑器的用法

    实验一: vi编辑器的模式切换 1.       实验目标:熟练掌握vi编辑器的三种模式间切换及其特点 2.       实验操作步骤: 步骤一: 进入vi编辑器即命令模式 进入vi编辑器可以在命令终 ...

  6. 对A*算法的改进

    对sunway程序中的BUG所进行的修改 需要注意的是Sunway上面文章“深入A*算法”中引用了一个A*的游戏程序进行讲解,并有这个源码的下载,不过它有一个不小的Bug, 就是新的子节点放入OPEN ...

  7. jdbc链接mysql转

    完整java开发中JDBC连接数据库代码和步骤   JDBC连接数据库 •创建一个以JDBC连接数据库的程序,包含7个步骤: 1.加载JDBC驱动程序: 在连接数据库之前,首先要加载想要连接的数据库的 ...

  8. CSS小记

    1.元素居中 (1)水平居中:指定宽度,然后margin auto 即可 .middle{ max-width:400px; //width:400px;//当浏览器被缩小,宽度小于元素宽度时,元素会 ...

  9. DedeCms 5.x 本地文件包含漏洞(respond方法)

    漏洞版本: DedeCms 5.x 漏洞描述: DedeCms是免费的PHP网站内容管理系统. plus/carbuyaction.php里没有对变量进行严格的过滤 出现漏洞的两个文件为: Inclu ...

  10. Mongodb For C# "Query" 对象常用的方法

    Query.All("name", "a", "b");//通过多个元素来匹配数组 Query.In("name", & ...