zoukankan      html  css  js  c++  java
  • FZU 2140 Forever 0.5

     Problem 2140 Forever 0.5

    Accept: 36    Submit: 113    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 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

    如果有就输出yes加上这n个点,如果没有就输出no

    思路 : 这个题一开始看样例觉得好复杂,其实画个图推一下倒是可以看出来,要满足上边的条件至少要是4个点,3个点的话是一个等边三角形,面积不符合。因为条件中老是提到1,其实就是一个半径为1的圆以原点为圆心。然后以原点和x轴画一个边长为1的等边三角形,这样的话就有三个点了,其实前四个点都是可以确定的,然后剩下的点从圆上找就可以了,主要是别离那三个点的距离大于1即可,因为圆上的点到圆心的距离都为1,其实就是将圆离散化。

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <iostream>
    #include <algorithm>
    #include <math.h>
    using namespace std ;
    double x[105],y[105] ;
    const double temp = 0.005 ;
    void chart()
    {
        x[0] = 0,y[0] = 0 ;
        x[1] = 1,y[1] = 0 ;
        x[2] = 0.5,y[2] = sqrt(1.0-0.25) ;
        x[3] = 0.5 ,y[3] = y[2]-1 ;
        for(int i = 4 ; i < 105 ; i++)
        {
            y[i] = i*temp ;
            x[i] = sqrt(1-y[i]*y[i]) ;
        }
    }
    int main()
    {
        int T,n ;
        chart() ;
        scanf("%d",&T) ;
        while(T--)
        {
            scanf("%d",&n) ;
            if(n < 4)
                printf("No
    ") ;
            else
            {
                printf("Yes
    ") ;
                for(int i = 0 ; i < n ; i++)
                    printf("%.6lf %.6lf
    ",y[i],x[i]) ;
            }
        }
        return 0 ;
    }
    View Code
  • 相关阅读:
    ubuntu配置实验
    初始linux系统--ubuntu
    部署WSUS服务(一)
    web站点启用https (二)
    web站点启用https (一)
    windows 域的安装方法
    链表大合集(一)
    神奇的幻方
    二叉树的存储结构 以及重建二叉树
    html列表
  • 原文地址:https://www.cnblogs.com/luyingfeng/p/3603716.html
Copyright © 2011-2022 走看看