博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4082 Hou Yi's secret(暴力)
阅读量:7086 次
发布时间:2019-06-28

本文共 2056 字,大约阅读时间需要 6 分钟。

直接6重循环就行了吧。。。判三角形相似直接从小到大枚举两向量夹角是否相等就行了。注意去重点跟三点共线就行了。。。

 

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define FF(i, a, b) for(int i=a; i
=b; i--)#define REP(i, n) for(int i=0; i
0) return Length(v3); else return fabs(Cross(v1, v2)) / Length(v1);}//点p在直线ab上的投影Point GetLineProjection(Point p, Point a, Point b){ Vector v = b-a; return a + v*(Dot(v, p-a) / Dot(v, v));}//点段相交判定bool SegmentItersection(Point a1, Point a2, Point b1, Point b2){ double c1 = Cross(a2-a1, b1-a1), c2 = Cross(a2-a1, b2-a1), c3 = Cross(b2-b1, a1-b1), c4 = Cross(b2-b1, a2-b1); return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4) < 0;}//点在线段上bool OnSegment(Point p, Point a1, Point a2){ return dcmp(Cross(a1-p, a2-p)) == 0 && dcmp(Dot(a1-p, a2-p)) < 0;}//多变形面积double PolygonArea(Point* p, int n){ double ret = 0; FF(i, 1, n) ret += Cross(p[i]-p[0], p[i+1]-p[0]); return ret/2;}Point read_point(){ Point a; scanf("%lf%lf", &a.x, &a.y); return a;}bool cmp(double a[], double b[]){ if(dcmp(a[0]-b[0])!=0) return 0; if(dcmp(a[1]-b[1])!=0) return 0; if(dcmp(a[2]-b[2])!=0) return 0; return 1;}const int maxn = 100;Point p[maxn];int n, cnt;double aa[10], bb[10];bool can(int i, int j, int k){ return dcmp(Cross(p[j]-p[i], p[k]-p[i])) != 0;}int main(){ Vector a = Vector(0, 1), b = Vector(0, 100); while(scanf("%d", &cnt), cnt) { REP(i, cnt) p[i] = read_point(); sort(p, p+cnt); n = unique(p, p+cnt) - p; int ans = 0; REP(i, n) FF(j, i+1, n) FF(k, j+1, n) { if(!can(i, j, k)) continue; int tmp = 0; aa[0] = Angel(p[j]-p[i], p[k]-p[i]); aa[1] = Angel(p[i]-p[j], p[k]-p[j]); aa[2] = Angel(p[i]-p[k], p[j]-p[k]); sort(aa, aa+3); REP(ii, n) FF(jj, ii+1, n) FF(kk, jj+1, n) { if(!can(i, j, k)) continue; bb[0] = Angel(p[jj]-p[ii], p[kk]-p[ii]); bb[1] = Angel(p[ii]-p[jj], p[kk]-p[jj]); bb[2] = Angel(p[ii]-p[kk], p[jj]-p[kk]); sort(bb, bb+3); if(cmp(aa, bb)) tmp++; } ans = max(ans, tmp); } printf("%d\n", ans); } return 0;}

 

 

转载地址:http://psgml.baihongyu.com/

你可能感兴趣的文章
dp - Google Code jam Qualification Round 2015 --- Problem B. Infinite House of Pancakes
查看>>
新纪元
查看>>
软件公司项目经理岗位职责
查看>>
Netty中的坑(下篇)
查看>>
SQL Server 2008 安装教程
查看>>
bootstrap精简教程
查看>>
C# 6.0 的那些事
查看>>
java的System.getProperty()方法能够获取的值
查看>>
堆是堆,栈归栈
查看>>
prepareCall()运行存储过程
查看>>
关于 ake sure class name exists, is public, and has an empty constructor that is public
查看>>
用C++做TerraExplorer开发(四)——实现HUD Layer(1)(转载)
查看>>
[.net 面向对象编程基础] (9) 类和类的实例
查看>>
语法面试等题目汇总
查看>>
Duilib技巧:背景图片平铺
查看>>
【转】Android出现“Read-only file system”解决办法
查看>>
基于jQuery左侧大图右侧小图切换代码
查看>>
机器学习:更多的数据总是优于更好的算法吗?
查看>>
Python 迭代器 & __iter__方法
查看>>
Machine Learning - XI. Machine Learning System Design机器学习系统的设计(Week 6)
查看>>