FOJ_2140_Forever 0.5_手动构造

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


题意:

给一个整数 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值