CF 306D(Polygon-多边形‘推进’oper)

D. Polygon
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarpus loves convex polygons, especially if all their angles are the same and all their sides are different. Draw for him any such polygon with the given number of vertexes.

Input

The input contains a single integer n (3 ≤ n ≤ 100) — the number of the polygon vertexes.

Output

Print n lines, containing the coordinates of the vertexes of the n-gon "xi yi" in the counter clockwise order. The coordinates of the vertexes shouldn't exceed 106 in their absolute value. The side lengths should fit within limits [1, 1000] (not necessarily integer). Mutual comparing sides and angles of your polygon during the test will go with precision of 10 - 3.

If there is no solution, print "No solution" (without the quotes).

Sample test(s)
input
8
output
1.000 0.000
7.000 0.000
9.000 2.000
9.000 3.000
5.000 7.000
3.000 7.000
0.000 4.000
0.000 1.000


我们定义多边形的'推进‘operation:



好了,推进实际上是把一条边向右推的操作。。

于是我们就能构造出n>4的解。。

n≤4时无解。。。这个显然吧、、、、

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
#include<complex>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (100+10)
#define eps (1e-3)
const long double pi=3.1415926;
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
int n;
complex<long double> a[MAXN],A,B;
long double rand(long double x)
{
	long double p=(long double)(rand());
	while (p>1) p/=10;
	return p*x;
}
int main()
{
//	freopen("CF306D.in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;srand(6);
	if (n<=4) {puts("No solution");return 0;}
	double e=2*pi/n,r=n>10?1000:100;
	Rep(i,n) a[i]=polar(r,e*i);
	long double t=r*sin(e/2)/sin(pi/2-e)/100;//表示最大可伸长的边的长度 
	
	long double k=0;
	Rep(i,n-1)
	{
		A=a[(i-1+n)%n],B=a[(i+2)%n];
		k+=0.5;
		//long double k=rand(t);
		a[i]+=k*(a[i]-A)/abs(a[i]-A);
		a[i+1]+=k*(a[i+1]-B)/abs(a[i+1]-B);
	}
	/*	
	long double p=0;
	Rep(i,n) p=max(p,abs(a[i].imag())),p=max(p,abs(a[i].real()));
	if (p>0)
	{
		long double cli=1000/p;
		Rep(i,n) a[i]*=cli;
	}*/
	cout.setf(ios::fixed);
	cout.precision(9);
	Rep(i,n) cout<<a[i].real()<<' '<<a[i].imag()<<endl;
	
	//Rep(i,n) printf("%.3llf %.3llf\n",a[i].real(),a[i].imag());
	
	return 0;
}










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值