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 ...
随机推荐
- 在EditText里输入小写字母时,将小写字母转化为大写显示
1.新建类继承ReplacementTransformationMethod 方法 public class test extends ReplacementTransformationMethod ...
- Python3基础 map+lambda 将指定系列元素乘2
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Pairs Forming LCM (LCM+ 唯一分解定理)题解
Pairs Forming LCM Find the result of the following code: ; i <= n; i++ ) for( int j = i; j ...
- HDU1556 Color the ball(差分数组)题解
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- 04_Windows平台Spark开发环境构建
Spark的开发环境,可以基于IDEA+Scala插件,最终将打包得到的jar文件放入Linux服务器上的Spark上运行 如果是Python的小伙伴,可以在Windows上部署spark+hadoo ...
- 字符集(编码)转换_Qt532_QString
1.网上的资料: 1.1.参考网址:http://blog.csdn.net/changsheng230/article/details/6588447 1.2.网页内容: “ Qt 使用Unicod ...
- placeholder的使用
1.定义 placeholder 属性提供可描述输入字段预期值的提示信息 该提示会在输入字段为空时显示,并会在字段获得焦点时消失. 注释:placeholder 属性适用于以下的 <input& ...
- Python map/reduce
2017-07-31 18:20:59 一.map函数 map():会根据提供的函数对指定序列做映射.第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 ...
- vue.js循环for(列表渲染)详解
vue.js循环for(列表渲染)详解 一.总结 一句话总结: v-for <ul id="example-1"> <li v-for="item in ...
- Sqlite3,维基百科中的练习:
https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store 两个相连的表格 Manufactures: code, name prod ...