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个点满足上面的条件。

然而1、2、3个点显然不满足。

然后4个点的时候排除正方形,只能画出下面这种图形满足条件:

然后,发现,若需加入第五个点,制约条件3要求下,第5个点仅能与四个点中一个点距离为1。

然后由于其余点距离范围的控制加上面积的控制。我可以将第五个点选在距离A很近的,而且在以B为圆心1为半径的弧AD上。

由于需要在AD弧内能放下100个点,所以每次远离A点水平距离0.001。这样100个点只有0.1。然而AD水平距离为0.5,所以0.001到0.005内都是可以的。

而如果取到0.0001这样小,由于精度只有10^-6次方,所以在计算距离的时候平方会导致精度丢失而使新点几乎和A点效果一致,导致条件三不满足。

然后由于原四边形面积是0.5,如果算上整个扇形的面积是0.5 + PI/6 - sqrt(3)/4 < 0.75。所以面积满足。

由于整个图形是在一个直径为1的圆内,距离也满足。

代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#define eps 0.001 using namespace std; double x[] = { , 0.5, , -0.5};
double y[] = {0.866025, , -0.133975, }; inline double pow2(double a)
{
return a*a;
} int n; void Work()
{
double xx, yy;
xx = x[];
for (int i = ; i < ; ++i)
printf("%.6lf %.6lf\n", x[i], y[i]);
n -= ;
xx -= eps;
for (int i = ; i < n; ++i)
{
yy = sqrt(-pow2(xx-x[]));
printf("%.6lf %.6lf\n", xx, yy);
xx -= eps;
}
} int main()
{
//freopen("test.in", "r", stdin);
int T;
scanf("%d", &T);
for (int times = ; times < T; ++times)
{
scanf("%d", &n);
if (n < )
printf("No\n");
else
{
printf("Yes\n");
Work();
}
}
return ;
}

ACM学习历程—FZU 2140 Forever 0.5(计算几何 && 构造)的更多相关文章

  1. FZU 2140 Forever 0.5 (几何构造)

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

  2. ACM学习历程—FZU 2144 Shooting Game(计算几何 && 贪心 && 排序)

    Description Fat brother and Maze are playing a kind of special (hentai) game in the playground. (May ...

  3. FZU 2140 Forever 0.5

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

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

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

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

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

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

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

  7. ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)

    Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...

  8. ACM学习历程—HDU1392 Surround the Trees(计算几何)

    Description There are a lot of trees in an area. A peasant wants to buy a rope to surround all these ...

  9. ACM学习历程—SGU 275 To xor or not to xor(xor高斯消元)

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=275 这是一道xor高斯消元. 题目大意是给了n个数,然后任取几个数,让他们xor和 ...

随机推荐

  1. java Map 实现类的对比

    java为数据结构中的映射定义了一个接口 java.util.Map ,他有四个实现类

  2. mysql忘记password

    有时候突然忘记MySQL的password会真的不爽,这里介绍一种MySQLpassword忘记时重置password的方法,操作系统win8,MySql version:5.6.10 1 在任务管理 ...

  3. 【Servlet与JSP】请求转发与重定向

    假设一个登录系统,要求用户输入用户名和密码: 用户在上面表单当中输入了信息之后,点击登录按钮(type="submit")将表单作为请求参数进行提交. 这一提交就有两种形式:get ...

  4. Android 开发小工具之:Tools 属性 (转)

    Android 开发小工具之:Tools 属性 http://blog.chengyunfeng.com/?p=755#ixzz4apLZhfmi 今天来介绍一些 Android 开发过程中比较有用但 ...

  5. os引导程序boot从扇区拷贝os加载程序loader文件到内存(boot copy kernel to mem in the same method)

    [0]README 0.1) 本代码旨在演示 在boot 代码中,如何 通过 loader文件所在根目录条目 找出该文件的 在 软盘所有全局扇区号(簇号),并执行内存中的 loader 代码: 0.2 ...

  6. python 基础 1.6 python 帮助信息及数据类型间相互转换

      一. 帮助信息   # dir() 方法  查看函数的方法   # help()   # type() 查看类型   name = raw_input('please input you name ...

  7. RTSP转RTMP-HLS网页无插件视频直播-EasyNVR功能介绍-音频开启

    EasyNVR简介 EasyNVR能够通过简单的摄像机通道配置.存储配置.云平台对接配置.CDN配置等,将统监控行业里面的高清网络摄像机IP Camera.NVR.移动拍摄设备接入到EasyNVR,E ...

  8. java 核心技术卷一 知识点

    第九章 集合 1.Iterator和Iterable接口类,作用. 2.Collection接口类,作用. 3.Map接口类,作用.

  9. Spring-data-redis:特性与实例(转载)

    原文地址:http://www.cnblogs.com/davidwang456/p/4915109.html Spring-data-redis为spring-data模块中对redis的支持部分, ...

  10. ubuntu把文件移动到指定的文件夹

    有个文件a.txt在/etc下,想把它移动到/etc/fuck文件夹中 cd /etc/fuck sudo mv a.txt 要移动到的文件夹 没报错就成功了