codeforces #306D Polygon 构造
来源:互联网 发布:手机大数据是什么意思 编辑:程序博客网 时间:2024/05/01 18:04
题目大意:给定
膜拜题解
其实我一开始想的是构造一个正
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define M 110#define PI 3.1415926535897932using namespace std;struct Point{ double x,y; Point() {} Point(double _,double __): x(_),y(__) {} friend Point operator + (const Point &p1,const Point &p2) { return Point(p1.x+p2.x,p1.y+p2.y); } friend Point operator - (const Point &p1,const Point &p2) { return Point(p1.x-p2.x,p1.y-p2.y); } friend double operator * (const Point &p1,const Point &p2) { return p1.x*p2.y-p1.y*p2.x; } friend Point operator * (const Point &p,double rate) { return Point(p.x*rate,p.y*rate); } friend Point Rotate (const Point &p,double alpha) { return Point(p.x*cos(alpha)-p.y*sin(alpha),p.x*sin(alpha)+p.y*cos(alpha) ); }}ans[M];struct Line{ Point p,v; Line() {} Line(const Point &_,const Point &__): p(_),v(__) {} friend Point Get_Intersection(const Line &l1,const Line &l2) { Point u=l1.p-l2.p; double temp=(l2.v*u)/(l1.v*l2.v); return l1.p+l1.v*temp; }};int n;int main(){ int i; cin>>n; if(n<=4) return cout<<"No solution"<<endl,0; Point v(-1,0); double len=450.0,delta=0.005; double alpha=2.0*PI/n; for(i=1;i<n;i++) { ans[i]=ans[i-1]+v*len; len+=delta; v=Rotate(v,-alpha); } ans[n]=Get_Intersection(Line(ans[n-1],v),Line(Point(0,0),Point(1,0))); for(i=n;i;i--) printf("%.10lf %.10lf\n",ans[i].x,ans[i].y); return 0;}
0 0
- codeforces #306D Polygon 构造
- codeforces 306D Polygon
- 【codeforces 755D】PolandBall and Polygon
- Codeforces 755D-PolandBall and Polygon
- 【构造】CodeForces 389D
- codeforces 655D (构造)
- Codeforces 550D 构造
- Codeforces 798D 构造
- codeforces 755 d PolandBall and Polygon(找规律)
- codeforces-755D-PolandBall and Polygon(数学题)
- Codeforces 755-D. PolandBall and Polygon(树状数组+计算几何)
- CF 306D(Polygon-多边形‘推进’oper)
- CodeForces 66D 数学构造
- codeforces GYM 101431D(构造)
- Codeforces 873D:构造题
- Codeforces Round #306 (Div. 2) D - Regular Bridge 构造
- Codeforces Round #306 (Div. 2) D. Regular Bridge (构造)
- codeforces #306 D 550D D. Regular Bridge(构造+图论)
- C++对象模型
- 123kan电影网-技术架构
- Managing Data in Containers
- office系列文件的加密检测
- OSS接口音量调节
- codeforces #306D Polygon 构造
- Linux桌面快捷方式 Desktop Entry 详解
- [LeetCode]-011-Container With Most Water
- No write method for property问题的解决
- Solr与MongoDB集成,实时增量索引
- Android第二十一天 整合ActionBar+ViewPager,PagerTabStrip的使用
- 线程的定义
- ubuntu安装redis
- 深度解析VC中的消息传递机制