杭电多校 1011 Regular polygon! 题解报告
来源:互联网 发布:用eclipse写java 编辑:程序博客网 时间:2024/06/16 09:11
题目意思:
很简单的题目意思,给你一系列的点的坐标,问你可以用这些点构造多少正多边形
其实就是找正方形的个数 这个是一个结论
等我晚上吃完饭回来 让总结
先上代码:
#include <cmath>#include <queue>#include <cstdio>#include <string>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 1000+5;int N,ans;struct SPoint { double x,y; SPoint() {} SPoint(int xx,int yy) : x(xx), y(yy) {} bool operator < (const SPoint& p) const { if(x == p.x) return y < p.y; return x < p.x; } bool operator == (const SPoint& p) const { return x==p.x&&y==p.y; }}pnt[maxn];//任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式://x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;//y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;void transXY(SPoint A, SPoint B, SPoint &C, int f) { int tx = B.x - A.x, ty = B.y - A.y; C.x = A.x - ty * f; C.y = A.y + tx * f;}int main() { //freopen("input.in","r",stdin); while(~scanf("%d",&N)&&N) { ans = 0; for(int i = 0;i < N;i++) scanf("%lf %lf",&pnt[i].x,&pnt[i].y); sort(pnt,pnt+N); for(int i = 0;i < N-3;i++) //① { for(int j = i+1;j < N-2;j++) //② { SPoint C,D; transXY(pnt[i],pnt[j],C,1); transXY(pnt[j],pnt[i],D,-1); if(binary_search(pnt+j,pnt+N,C)&&binary_search(pnt+j,pnt+N,D)) ans++; //③ transXY(pnt[i],pnt[j],C,-1); transXY(pnt[j],pnt[i],D,1); if(binary_search(pnt+j,pnt+N,C)&&binary_search(pnt+j,pnt+N,D)) ans++; //④ } } printf("%d\n",ans); } return 0;}
阅读全文
0 0
- 杭电多校 1011 Regular polygon! 题解报告
- 2017年多校 1011 Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- hdu6055 17多校二1011 Regular polygon
- 2017多校2 1011 Regular polygon
- 2017 杭电多校联赛第二场 1011 Regular polygon(多个点求正方形个数)POJ 2002
- hdu 4033 Regular Polygon
- UVA12300-Smallest Regular Polygon
- 2011 Regular Polygon
- [HDU]-6055 Regular polygon
- 多校6055 Regular polygon
- Regular polygon HDU
- 字符串长度乘积最大值 位操作
- Android 使用第三方SDK—友盟实现分享功能
- 如何学习技术(任何东西),重点是什么(转自知乎)
- SpringMVC
- vue-cli安装规范
- 杭电多校 1011 Regular polygon! 题解报告
- 使用 acl 库编写多线程应用程序
- Spark编程之基本的RDD算子coalesce, repartition, checkpoint
- MongoDB四(插入文档)
- Android GUI FramebufferNativeWindow ANativeWindow
- Win32 SOCKET之UDP
- 目前为止最全的微信小程序项目实例
- 理解RESTful架构
- OpenGL ES应用开发实践指南(android 卷)笔记 第一章