博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bear and Floodlight 状态压缩DP啊
阅读量:7138 次
发布时间:2019-06-28

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

Time Limit: 4000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

[]   [Go Back]   []  

Description

One day a bear lived on the Oxy axis. He was afraid of the dark, so he couldn't move at night along the plane points that aren't lit. One day the bear wanted to have a night walk from his house at point (l, 0) to his friend's house at point (r, 0), along the segment of length (r - l). Of course, if he wants to make this walk, he needs each point of the segment to be lit. That's why the bear called his friend (and yes, in the middle of the night) asking for a very delicate favor.

The Oxy axis contains n floodlights. Floodlight i is at point (xi, yi) and can light any angle of the plane as large as ai degree with vertex at point(xi, yi). The bear asked his friend to turn the floodlights so that he (the bear) could go as far away from his house as possible during the walking along the segment. His kind friend agreed to fulfill his request. And while he is at it, the bear wonders: what is the furthest he can go away from his house? Hep him and find this distance.

Consider that the plane has no obstacles and no other light sources besides the floodlights. The bear's friend cannot turn the floodlights during the bear's walk. Assume that after all the floodlights are turned in the correct direction, the bear goes for a walk and his friend goes to bed.

Input

The first line contains three space-separated integers nlr(1 ≤ n ≤ 20;  - 105 ≤ l ≤ r ≤ 105). The i-th of the next n lines contain three space-separated integers xiyiai( - 1000 ≤ xi ≤ 1000; 1 ≤ yi ≤ 1000; 1 ≤ ai ≤ 90) — the floodlights' description.

Note that two floodlights can be at the same point of the plane.

Output

Print a single real number — the answer to the problem. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 6.

Sample Input

Input
2 3 5 3 1 45 5 1 45
Output
2.000000000
Input
1 0 1 1 1 30
Output
0.732050808
Input
1 0 1 1 1 45
Output
1.000000000
Input
1 0 2 0 2 90
Output
2.000000000
1 #include 
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 #define PI acos(-1) 8 #define eps 0.0000000001 9 struct point10 {11 double x,y,a;12 };13 point p[50];14 double dp[1<<20];15 double dist(double x,double y,double x1,double y1)16 {17 return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));18 }19 double solve(double s,int k)20 {21 double B=atan2(p[k].y,p[k].x-s),A=p[k].a*PI/180;22 double C=max(0.0,PI-A-B),l=dist(s,0.0,p[k].x,p[k].y);23 //cout<
<<" "<<<" "<
<<" "<
=r)ok=1;49 }50 }51 if(ok)52 {53 printf("%.9lf\n",r-l);54 //cout<<"YES"<
View Code

 

转载于:https://www.cnblogs.com/ERKE/p/3903586.html

你可能感兴趣的文章
图像局部特征点检测算法综述
查看>>
未找到导入的项目,请确认 <Import> 声明中的路径正确
查看>>
Swift游戏实战-跑酷熊猫 08 产生源源不断的移动平台
查看>>
Java Notes 00 - Singleton Pattern(单例总结)
查看>>
【转】Linux内核源码分析方法
查看>>
.NET分布式事务处理(转)
查看>>
当一个项目中同时存在webroot和webcontext时
查看>>
在Java中打开浏览器
查看>>
取一种类型里面的产品销售前3甲的数据Sql
查看>>
索引初探(二)
查看>>
linux 打造man中文帮助手册
查看>>
[数分提高]2014-2015-2第6教学周第1次课讲义 3.3 Taylor 公式
查看>>
Android 最火框架XUtils之注解机制详解
查看>>
spring4.x注解概述
查看>>
Dynamic CRM 2015学习笔记(6)没有足够的权限 - 您没有访问这些记录的权限。请联系 Microsoft Dynamics CRM 管理员...
查看>>
C++序列化、反序列化
查看>>
Mysql学习笔记(七)查(补充)
查看>>
[裴礼文数学分析中的典型问题与方法习题参考解答]4.5.5
查看>>
自然科学与社会科学的区别
查看>>
访问者模式
查看>>