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. spring + jodd 实现文件上传

    String tempDir = SystemUtil.getTempDir(); // 获得系统临时文件夹 String prefix = UUID.randomUUID().toString(). ...

  2. Linux kernel 2.6下的modules编译与KBuild

    转载:http://blog.sina.com.cn/s/blog_602f87700100dq1u.html Sam之前在Linux kernel 2.4下写过一些driver.但自从转到kerne ...

  3. 制作FAT12软盘以查看软盘的根目录条目+文件属性+文件内容

    [-1]Before for specific info , please visit http://wiki.osdev.org/Loopback_Device [0]我们先上干货,看到效果后,我们 ...

  4. Android发送验证码的倒计时button

    1 直接上图 2 原理 原理非常easy,就是把对应的倒计时逻辑等封装到一个控件中,并向外部提供接口. 3 代码 import java.util.Timer; import java.util.Ti ...

  5. poj 2151Check the difficulty of problems<概率DP>

    链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~  求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...

  6. grok表达式

    grok表达式 grok其实就是封装了各种常用的正则表达式,屏蔽了直接写正则的复杂性:通过它可以提取日志内容,按照自己指定的格式输出到kibana. http://udn.yyuap.com/doc/ ...

  7. 怎么使用Aspose.Cells读取excel 转化为Datatable

    说明:vs2012 asp.net mvc4 c# 使用Aspose.Cells 读取Excel 转化为Datatable 1.HTML前端代码 <%@ Page Language=" ...

  8. python get post模拟请求

    1.使用get方式时.url相似例如以下格式: &op=bind   GET报问头例如以下: &n=asa HTTP/1.1    Accept: */*    Accept-Lang ...

  9. MongoDB入门学习(三):MongoDB的增删查改

            对于我们这样的菜鸟来说,最重要的不是数据库的管理,也不是数据库的性能,更不是数据库的扩展,而是怎么用好这款数据库,也就是一个数据库提供的最核心的功能,增删查改.         由于M ...

  10. [2018-12-18]ABP中的AsyncCrudAppService介绍

    前言 自从写完上次略长的<用ABP入门DDD>后,针对ABP框架的项目模板初始化,我写了个命令行工具Abp-CLI,其中子命令abplus init可以从github拉取项目模板以初始化项 ...