FOJ_2140_Forever 0.5_手动构造

来源:互联网 发布:安卓版打谱软件 编辑:程序博客网 时间:2024/06/08 19:21

新学期第一场组队比赛,打得还不错


题意:

给一个整数 N,判断是否在笛卡尔坐标系内存在这样的N个点,满足下面的条件:

1. 任意两个点的距离不大于1

2. 任意一个点和原点的距离不大于1

3. 有正好N对点,它们之间的距离正好是1

4. 这些点组成的凸包的面积不小于0.5

5. 这些点组成的凸包的面积不大于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.



很奇怪的题目要求。。。不是我做的,但是我想到如果是我做的话应该是做不出来。队友的做法是把一个点放在原点,然后其他点都放在半径为1的圆上面,这样就有N-1对距离正好是1的点了,然后要使圆周上的N-1个点之间的最大距离不大于1,正好又还需要一对距离为1的,就让这些点的最大距离为1,这样前三个条件就都满足了。第五条肯定满足,因为这个凸多边形的面积小于对应60度角扇形的面积,扇形面积比0.75要小,之后就是第四条条件。首先肯定是点越多面积越大,三个点是面积小于0.5,理论上可以用二分来找一个临界的点的个数,但是算凸多边形面积着实麻烦,当时队友试了一下4个点,然后发现可以唉。然后就代码模拟算点坐标就行了。


#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;struct point{double x,y;};point a[105];int n;const double pi=acos(-1.0);int main(){int T;scanf("%d",&T);while (T--){scanf("%d",&n);if (n<=3) {printf("No\n");continue;}double aa=(pi/3)/(n-2);printf("Yes\n");printf("0.000000 0.000000\n");for (int i=0;i<n-1;i++){a[i].x=cos(i*aa);a[i].y=sin(i*aa);printf("%.6lf %.6lf\n",a[i].x,a[i].y);}}return 0;}


0 0
原创粉丝点击