0
点赞
收藏
分享

微信扫一扫

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

醉东枫 2022-10-25 阅读 21



D. Polygon



time limit per test



memory limit per test



input



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



n (3 ≤ n ≤ 100) — the number of the polygon vertexes.



Output



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:

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


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

于是我们就能构造出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 条评论