ACM学习历程—FZU 2140 Forever 0.5(计算几何 && 构造)
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
Sample Output
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(计算几何 && 构造)的更多相关文章
- FZU 2140 Forever 0.5 (几何构造)
Forever 0.5 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- ACM学习历程—FZU 2144 Shooting Game(计算几何 && 贪心 && 排序)
Description Fat brother and Maze are playing a kind of special (hentai) game in the playground. (May ...
- FZU 2140 Forever 0.5
Problem 2140 Forever 0.5 Accept: 36 Submit: 113 Special JudgeTime Limit: 1000 mSec Memory ...
- FZU 2140 Forever 0.5(找规律,几何)
Problem 2140 Forever 0.5 Accept: 371 Submit: 1307 Special Judge Time Limit: 1000 mSec Memory Limit : ...
- fzu Problem 2140 Forever 0.5(推理构造)
题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...
- FZU 2140 Forever 0.5(将圆离散化)
主要就是将圆离散化,剩下的都好办 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)
Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...
- 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 ...
- ACM学习历程—SGU 275 To xor or not to xor(xor高斯消元)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=275 这是一道xor高斯消元. 题目大意是给了n个数,然后任取几个数,让他们xor和 ...
随机推荐
- 关于安装oracle 11g client 出现安装先决条件检查全部失败
本文转自:https://blog.csdn.net/iloli/article/details/45244159 今天我在安装Oracle11gClient时,全部显示成N/A,Oracle无法执行 ...
- 必会必知git
git必会必知 1 前言 git前身是BitKeeper,但是他不是开源软件,不符合当时开源趋势,于是就会有了开源的git,git开发只用了十天时间.目前git是公司开发必不可少的一个工具,用于多 ...
- js 第一篇(常用交互方法)
1. cocument.write("content") //向html 直接写入内容 2. alert("content") // 警告对话框 3. conf ...
- 进程间的八种通信方式----共享内存是最快的 IPC 方式
1.无名管道( pipe ):管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程间使用.进程的亲缘关系通常是指父子进程关系. 2.高级管道(popen):将另一个程序当做一个新 ...
- 初探swift语言的学习笔记四-2(对上一节有些遗留进行处理)
作者:fengsh998 原文地址:http://blog.csdn.net/fengsh998/article/details/30314359 转载请注明出处 假设认为文章对你有所帮助,请通过留言 ...
- Mac 常用属性
如果需要让隐藏的文件可见. 具体做法就是打开一个Terminal终端窗口,输入以下命令: 对于OS X Mavericks 10.9: defaults write com.apple.finder ...
- python编程基础:《http://www.cnblogs.com/wiki-royzhang/category/466416.html》
windows自动化 http://www.cnblogs.com/wiki-royzhang/category/466416.html
- 【BZOJ4710】[Jsoi2011]分特产 组合数+容斥
[BZOJ4710][Jsoi2011]分特产 Description JYY 带队参加了若干场ACM/ICPC 比赛,带回了许多土特产,要分给实验室的同学们. JYY 想知道,把这些特产分给N 个同 ...
- BZOJ3878: [Ahoi2014&Jsoi2014]奇怪的计算器
BZOJ3878: [Ahoi2014&Jsoi2014]奇怪的计算器 Description [故事背景] JYY有个奇怪的计算器,有一天这个计算器坏了,JYY希望你能帮助他写 一个程序来模 ...
- Java for LeetCode 100 Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...