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

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, 0.5,         0, -0.5};
double y[] = {0.866025,   0, -0.133975,    0};

inline double pow2(double a)
{
    return a*a;
}

int n;

void Work()
{
    double xx, yy;
    xx = x[0];
    for (int i = 0; i < 4; ++i)
        printf("%.6lf %.6lf\n", x[i], y[i]);
    n -= 4;
    xx -= eps;
    for (int i = 0; i < n; ++i)
    {
        yy = sqrt(1-pow2(xx-x[1]));
        printf("%.6lf %.6lf\n", xx, yy);
        xx -= eps;
    }
}

int main()
{
    //freopen("test.in", "r", stdin);
    int T;
    scanf("%d", &T);
    for (int times = 0; times < T; ++times)
    {
        scanf("%d", &n);
        if (n < 4)
            printf("No\n");
        else
        {
            printf("Yes\n");
            Work();
        }
    }
    return 0;
}
时间: 2024-12-29 06:43:20

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 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

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

Description Fat brother and Maze are playing a kind of special (hentai) game in the playground. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.) But as they don’t like using repellent while playing this kind of special (hent

【构造】 FZU 2140 Forever 0.5

点击打开链接 题意:输入N,表示有N个点, 要求: 1.任意两点的距离≤ 1.0 2.每个点与原点的距离≤1.0 3.有N对点间的距离=1.0 4.N个点形成的面积≥0.5 ≤0.75 可以先取一个以原点为顶点,另外两个点在单位圆上的正三角形 其他的点就在圆弧BC上 将BC等分 而且N==4时 第四个点必须要在BC中点上 #include <cstdio> #include <cstdlib> #include <cstring> #include <climit

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

Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set around them. The magic forms a circle, which covers those three wizards, in other words, all of them are inside or on the border of the circle. And due

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 trees. So at first he must know the minimal required length of the rope. However, he does not know how to calculate it. Can you help him?        The

FZU OJ 2140 Forever 0.5 (几何)

Problem 2140 Forever 0.5 Accept: 269    Submit: 934    Special Judge Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Given an integer N, your task is to judge whether there exist N points in the plane such that satisfy the follo

ACM学习历程—HDU 4726 Kia&#39;s Calculation( 贪心&amp;&amp;计数排序)

DescriptionDoctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4567+5789, she will get 9246, and for 12

ACM学习历程—HDU 5023 A Corrupt Mayor&#39;s Performance Art(广州赛区网赛)(线段树)

Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sell the worthless painting at a high price to someone who wants to bribe him/her on an auction, this seemed a safe way for mayor X to make money. Becaus

ACM学习历程—UESTC 1226 Huatuo&#39;s Medicine(数学)(2015CCPC L)

题目链接:http://acm.uestc.edu.cn/#/problem/show/1226 题目就是构造一个对称的串,除了中间的那个只有1个,其余的两边都是对称的两个,自然答案就是2*n-1. 代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <algorithm> #