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.
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
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.
This problem is special judge.
题意 :给你一个数n,让你找出n个点,满足一下关系:
如果有就输出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\n") ; else { printf("Yes\n") ; for(int i = 0 ; i < n ; i++) printf("%.6lf %.6lf\n",y[i],x[i]) ; } } return 0 ; }