bzoj1091
题解:
暴力枚举顺序
然后计算几何
代码:
#include<bits/stdc++.h>
int n,id[],lp=;
double v1,v2,ans=1e10;
struct pos
{
double x,y;
void init(){scanf("%lf%lf",&x,&y);}
pos operator+(pos a){return (pos){x+a.x,y+a.y};}
pos operator-(pos a){return (pos){x-a.x,y-a.y};}
pos operator*(double a){return (pos){x*a,y*a};}
double operator*(pos a){return x*a.y-y*a.x;}
double dot(pos a){return x*a.x+y*a.y;}
double abs(){return sqrt(x*x+y*y);}
}ps[];
double mn,mx;
struct line
{
pos a,b;
void chk(line w)
{
double c=w.b*b;
if(c==)return;
c=(a*w.b+w.b*w.a)/c;
if(c>0.5)c<mx&&(mx=c);
else c>mn&&(mn=c);
}
}ls[],l0[];
int main()
{
scanf("%lf%lf%d",&v1,&v2,&n);
for (int i=;i<=n;i++)ps[i].init(),id[i]=i;
ps[n+]=ps[];
pos p1=(pos){,},p2=(pos){v1,},p3=(pos){v1,v2},p4=(pos){,v2};
ls[lp++]=(line){p1,p2-p1};
ls[lp++]=(line){p2,p3-p2};
ls[lp++]=(line){p3,p4-p3};
ls[lp++]=(line){p4,p1-p4};
for (int i=;i<=n;++i)l0[i]=(line){ps[i],ps[i+]-ps[i]};
do
{
lp=;
double s=;
for (int i=;i<=n;i++)
{
int w=id[i];
mn=-1e10,mx=1e10;
for (int j=;j<lp;j++)l0[w].chk(ls[j]);
ls[lp++]=l0[w];
s+=(mx-mn)*l0[w].b.abs();
}
if (s<ans)ans=s;
}while(std::next_permutation(id+,id+n+));
printf("%.3f",ans);
return ;
}
bzoj1091的更多相关文章
- 【题解】切割多边形 [SCOI2003] [P4529] [Bzoj1091]
[题解]切割多边形 [SCOI2003] [P4529] [Bzoj1091] 传送门:切割多边形 \(\text{[SCOI2003] [P4529]}\) \(\text{[Bzoj1091]}\ ...
- bzoj1091: [SCOI2003]切割多边形
Description 有一个凸p边形(p<=8),我们希望通过切割得到它.一开始的时候,你有一个n*m的矩形,即它的四角的坐标分别为(0,0), (0,m), (n,0), (n,m).每次你 ...
- BZOJ第1页养成计划
嗯,用这篇博客当一个目录,方便自己和学弟(妹?)们查阅.不定期更新. BZOJ1000 BZOJ1001 BZOJ1002 BZOJ1003 BZOJ1004 BZOJ1005 ...
- BZOJ 1091([SCOI2003]分割多边形-分割直线)
1091: [SCOI2003]分割多边形 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 223 Solved: 82 [Submit][id=10 ...
随机推荐
- 字符编码之间的相互转换 UTF8与GBK(转载)
转载自http://www.cnblogs.com/azraelly/archive/2012/06/21/2558360.html UTF8与GBK字符编码之间的相互转换 C++ UTF8编码转换 ...
- Java集合总结(List、Map、Set)
集合的引入 当我们有种需求,需要存储多个元素的结构时,我们前面讲过数组,数组可以存储.但是数组也有它的弊端,使用的时候,必须先定义好长度,也就是数组的长度是固定,不能根据我们的需求自动变长或者变短. ...
- MSM8937系统启动流程【转】
本文转载自:https://blog.csdn.net/chenzhen1080/article/details/54945992?utm_source=blogxgwz8 1 Boot Addres ...
- ArchLinux For Arm 树莓派开机自启动脚本rc.local
今天折腾了下树莓派的迅雷固件,迅雷的安装很顺利,解压直接运行portal 就搞定了, 但是自启动就有问题了,由于新版的ArchLinux切换到systemd,不但rc.conf省了,连rc.local ...
- Leetcode——Target Sum
Question You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you ha ...
- Spring编译AOP项目报错
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram ...
- js自动小轮播
使用定时器,换个图片地址. 从1到5换,如果大于5了再跳到1,点击停止时关闭定时器. <!-- Author: XiaoWen Create a file: 2016-12-08 13:19:2 ...
- Codeforces Beta Round #95 (Div. 2) C. The World is a Theatre 组合数学
C. The World is a Theatre There are n boys and m girls attending a theatre club. To set a play " ...
- MSVC_代码优化
测试环境: Win7x64 cn_visual_studio_2010_ultimate_x86_dvd_532347.iso qt-opensource-windows-x86-msvc2010_o ...
- 《剑指offer》第四十题(最小的k个数)
// 面试题40:最小的k个数 // 题目:输入n个整数,找出其中最小的k个数.例如输入4.5.1.6.2.7.3.8 // 这8个数字,则最小的4个数字是1.2.3.4. #include < ...