Forever 0.5 FZU - 2140 (思维+计算几何+构造)

Forever 0.5

FZU - 2140

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.0
  • 所有点到原点的距离不大于1.0
  • 恰好有N对点的距离为1.0
  • 由这些点构成的n边形的面积不小于0.5
  • 由这些点构成的n边形的面积不大于0.75

思路:观察发现当n<=3的时候一定不行因为n <= 2无法找到两对点距离为1,只有一对

n = 3时,我们只能构造一个等边三角形,面积为√3/4小于0.5不符合题意

n>3时,我们可以从这个等边三角形的基础上进行加点

要是再加一点那么得多一对点距离恰好为1,那么就加在以等边三角形为半径的任意两点为端点的弧上即可,那么新加的点在弧上,这个点和圆心(三角形的另一个点)距离就是1,如下图,新加的点是D在弧CB,则D和A距离就是1


而且加上这一个部分的面积就可以满足条件

因为新加一个点多一个钝角三角形CDB它的面积是1/2 * 1 * (1 - √3/2) = 0.067

等边三角形面积√3/4=0.43312  相加面积为0.50012

所以之后加多少点只需要加在这个弧上即可,因为这个弧是1/6圆面积0.5233所以面积永远满足

而且题目没要求必须是不同的点,所以我们输出三个点,剩下的n-3个只需要输出那第四个点即可

思维啊!!当时就是想不到

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
    int t,n,cas = 0;
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        if(n <= 3) printf("No\n");
        else{
            printf("Yes\n");
            printf("%.6f %.6f\n",0.0,0.0);
            printf("%.6f %.6f\n",-0.5,sqrt(3.0) / 2.0);
            printf("%.6f %.6f\n",0.5,sqrt(3.0) / 2.0);
            for(int i = 0; i < n-3; i++){
                printf("%.6f %.6f\n",0.0,1.0);
            }
        }
    }
    return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值