虽然说是几何常识乱搞,但是想不到啊。。

题意:n个点取4个组成矩形,使面积最大,求面积。 n<=1500

题解:

  1.对角线相等且相互交于中点的四边形是矩形。

  2.矩形四点共圆。

  所以$n^2$枚举边,把线段中点和长度打包pair

  如果两条线的pair相等则可以构成一个圆,把相等的线段平方级枚举即可。

  考虑一个圆上的整点不多,常数小,所以没有T。。注意精度问题。

  【学习】http://blog.csdn.net/wzq_qwq/article/details/49005387

  感觉自己代码自带大常数。。有看出原因的,望留言指正谢谢:)

  

 #include <bits/stdc++.h>

 using namespace std;

 struct node
{
pair<int,int> pr; long long len; int x,y;
bool operator<(const node & temp)const
{
if(pr!=temp.pr)return pr<temp.pr;
return len<temp.len;
}
bool operator>(const node & temp)const
{ return temp<*this; }
bool operator==(const node & temp)const
{ return !(*this<temp) && !(temp<*this); }
}vec[*]; pair<int,int> p[]; double Dis(const int x,const int y)
{
return sqrt(1.0*(p[x].first-p[y].first)*(p[x].first-p[y].first)+
1.0*(p[x].second-p[y].second)*(p[x].second-p[y].second));
} int main()
{
int n,tot=;
scanf("%d",&n);
for(int i=;i<=n;++i)
scanf("%d%d",&p[i].first,&p[i].second),
p[i].first<<=,p[i].second<<=;
for(int i=;i<=n;++i) for(int j=;j<=n;++j)
vec[++tot]=(node)
{
make_pair((p[i].first+p[j].first)>>,(p[i].second+p[j].second)>>),
1LL*(p[i].first-p[j].first)*(p[i].first-p[j].first)+
1LL*(p[i].second-p[j].second)*(p[i].second-p[j].second), i,j
}; sort(vec+,vec+tot+); long long Ans=;
for(int i=;i<=tot;++i)
{
int l=i,r; while(vec[i]==vec[i-])i++; r=i-;
for(int j=l;j<=r;++j) for(int k=l;k<j;++k)
{
long long temp=(long long)(Dis(vec[j].x,vec[k].x)*
Dis(vec[j].x,vec[k].y)+0.5);
if(temp>Ans)Ans=temp;
}
} printf("%lld\n",Ans/);
return ;
}

最新文章

  1. Thymeleaf
  2. python导入模块和包的使用
  3. lintcode :Coins in Line II 硬币排成线 II
  4. &lt;c:if&gt;条件判断 和 取值做乘法运算
  5. Linux How to add a new disk to LVM
  6. 【转载】正则表达式学习 &amp; ASCII码表
  7. [改善Java代码]断言绝对不是鸡肋
  8. Linux free字段解析
  9. Linux上安装JDK环境变量配置
  10. iOS设计模式解析(四)组合模式
  11. hdu1028(整数划分问题)
  12. 初识Hibernate之关联映射(一)
  13. c++学习笔记---01---C++语言与OO思想介绍
  14. Visual Studio中将打开的代码与类文件进行关联
  15. css文本样式-css学习之旅(4)
  16. Transformer【Attention is all you need】
  17. C++ 使用命名规范
  18. Python pickle使用
  19. OpenWrt挂载移动硬盘实现脱机下载
  20. String 练习

热门文章

  1. JavaScript--userAgent
  2. UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\u8888′ in position 0: ordinal not in range(168)
  3. 2017青岛网络赛1011 A Cubic number and A Cubic Number
  4. 用Movie显示gif(2)GifView
  5. 中国移动Lumia机强制升级Windows10手机开发者预览版的方法
  6. P1044 栈
  7. ValueError: multi-byte encodings are not supported
  8. 前端面试题HTML
  9. C语言中结构体大小计算
  10. 编写Java脚本统计工程代码总行数