codeforces 306D Polygon
来源:互联网 发布:java判断字符集 编辑:程序博客网 时间:2024/05/01 08:02
遇到构造题就碰灰。。。。
只能想到3、4是无解的。。。。
5,6,7……怎么构造呢?
然后就去看别人程序。。。。不出所料,短短几行
大致算法如下:
从原点开始,规定一个基本长度len,原点先向正左方向走len得到点p1。
将len+=delta,从p1转一定的角度(根据不同的多边形很容易算出),从p1走到p2
如此循环直到搞定n-1个点,最后一个点怎么确定?其实只要保证其在x轴上,那么所有的内角相同,边长不同很容易得到了
#include <cmath>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n,i; struct Point{ double x,y; Point operator +(const Point &a) const { return (Point){x+a.x, y+a.y}; } Point operator -(const Point &a) const { return (Point){x-a.x, y-a.y}; } Point operator *(const double &a) const { return (Point){x*a, y*a}; } Point operator /(const double &a) const { return (Point){x/a, y/a}; }} P[200];int main(){ //freopen("235C.in","r",stdin); //freopen("235C.out","w",stdout); scanf("%d",&n); if (n<=4) {printf("No solution\n");return 0;} double len=300, dlt=0.01; Point w; for (i=1;i<n;i++){ w = (Point) { cos(2*M_PI/n*(i-1)), sin(2*M_PI/n*(i-1)) }; P[i]=P[i-1]+w*len; len+=dlt; } w = (Point) { cos(2*M_PI/n*(n-1)), sin(2*M_PI/n*(n-1)) }; P[n]=P[n-1]-w*(P[n-1].y/w.y); for (i=1;i<=n;i++) printf("%.3lf %.3lf\n",P[i].x,P[i].y); return 0;}
0 0
- codeforces 306D Polygon
- codeforces #306D Polygon 构造
- 【codeforces 755D】PolandBall and Polygon
- Codeforces 755D-PolandBall and Polygon
- codeforces 755 d PolandBall and Polygon(找规律)
- codeforces-755D-PolandBall and Polygon(数学题)
- Codeforces 755-D. PolandBall and Polygon(树状数组+计算几何)
- CF 306D(Polygon-多边形‘推进’oper)
- codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon
- Codeforces 8VC Venture Cup 2017 - Elimination Round D.PolandBall and Polygon
- codeforces 755D PolandBall and Polygon(直线分割平面-树状数组优化查询)
- Unity 3D Polygon Collider2D 使用方法
- Unity3D下修改Polygon Collider 2D
- polygon
- Polygon
- Codeforces Round #306 (Div. 2) D-E
- Codeforces Round #306 (Div. 2)D
- Polygon Collider 2D无法编辑的问题
- 2015-02-17字符界面装逼指南
- PE文件结构详解(二)可执行文件头
- Catia使用LMT LicManager系统后的效果数据分析
- WebService框架整理(一) Axis1
- 在csdn 上安个家,记录编程的点滴
- codeforces 306D Polygon
- LeetCode(50) N-Queens II
- ros3.3静态IP上网配置
- 基于XMPP协议的手机多方多端即时通讯方案
- C# OPenCV(Emgu) (转载加编辑)
- java工程编译成exe文件的方法。
- 彻底让我弄懂this,call,apply的文章
- 图解WildFly 8.X配置HTTPS
- 修改dbwr后台进程数量