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