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

[Submit]   [Go Back]   [Status]

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

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define PI acos(-1)
#define eps 0.0000000001
struct point
{
double x,y,a;
};
point p[];
double dp[<<];
double dist(double x,double y,double x1,double y1)
{
return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
}
double solve(double s,int k)
{
double B=atan2(p[k].y,p[k].x-s),A=p[k].a*PI/;
double C=max(0.0,PI-A-B),l=dist(s,0.0,p[k].x,p[k].y);
//cout<<A<<" "<<B<<" "<<C<<" "<<s+l*sin(A)/sin(C)<<endl;
return s+l*sin(A)/sin(C);
}
int main()
{
// freopen("in.txt","r",stdin);
int n,i,size,j,ok;
double l,r;
while(~scanf("%d%lf%lf",&n,&l,&r))
{
ok=;
for(i=;i<n;i++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].a);
if(p[i].y<)p[i].y=-p[i].y;
}
size=<<n;
for(i=;i<size;i++)dp[i]=l;
for(i=;!ok&&i<size;i++)
{
for(j=;!ok&&j<n;j++)
{
if(i&(<<j))
continue;
dp[i|(<<j)]=max(dp[i|(<<j)],solve(dp[i],j));
if(dp[i|(<<j)]>=r)ok=;
}
}
if(ok)
{
printf("%.9lf\n",r-l);
//cout<<"YES"<<endl;
}
else
printf("%.9lf\n",dp[(<<n)-]-l);
}
}

Bear and Floodlight 状态压缩DP啊的更多相关文章

  1. hoj2662 状态压缩dp

    Pieces Assignment My Tags   (Edit)   Source : zhouguyue   Time limit : 1 sec   Memory limit : 64 M S ...

  2. POJ 3254 Corn Fields(状态压缩DP)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4739   Accepted: 2506 Descr ...

  3. [知识点]状态压缩DP

    // 此博文为迁移而来,写于2015年7月15日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102w6jf.html 1.前 ...

  4. HDU-4529 郑厂长系列故事——N骑士问题 状态压缩DP

    题意:给定一个合法的八皇后棋盘,现在给定1-10个骑士,问这些骑士不能够相互攻击的拜访方式有多少种. 分析:一开始想着搜索写,发现该题和八皇后不同,八皇后每一行只能够摆放一个棋子,因此搜索收敛的很快, ...

  5. DP大作战—状态压缩dp

    题目描述 阿姆斯特朗回旋加速式阿姆斯特朗炮是一种非常厉害的武器,这种武器可以毁灭自身同行同列两个单位范围内的所有其他单位(其实就是十字型),听起来比红警里面的法国巨炮可是厉害多了.现在,零崎要在地图上 ...

  6. 状态压缩dp问题

    问题:Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Ev ...

  7. BZOJ-1226 学校食堂Dining 状态压缩DP

    1226: [SDOI2009]学校食堂Dining Time Limit: 10 Sec Memory Limit: 259 MB Submit: 588 Solved: 360 [Submit][ ...

  8. Marriage Ceremonies(状态压缩dp)

     Marriage Ceremonies Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  9. HDU 1074 (状态压缩DP)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:有N个作业(N<=15),每个作业需耗时,有一个截止期限.超期多少天就要扣多少 ...

随机推荐

  1. PS软件操作应用—文字特效

      前  言 JRedu 在图像调整和文字工具的分享文章中,对文字工具做了简单的介绍,包括了文字的字体.字号大小.颜色以及字间距行距等等的设置和修改,都是一些基本的功能,在这次的分享中我们介绍下文字特 ...

  2. 网络协议UDP

    ------------------------------互联网协议与协议族------------------------------tcp/ip协议介绍:计算机网络协议,不同类型不同厂家之间的终 ...

  3. ScrollView嵌套ListView只显示一行

    错误描述 ScrollView嵌套ListView中导致ListView高度计算不正确,只显示一行. 解决方法 重写ListView的onMeasure方法,代码如下. @Override publi ...

  4. mysql数据类型double和decimal区别详解

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt336 实数是带有小数部分的数字.然而,它们不只是为了存储小数部分,也可以使用 ...

  5. 通过编译lambda表达式来创建实例(可在反射时候用,效率比反射高一些)

    原文地址:https://rogerjohansson.blog/2008/02/28/linq-expressions-creating-objects/ 据说编译lambda创建实例是比反射快.实 ...

  6. 简单理解java中timer的schedule和scheduleAtFixedRate方法的区别

    timer的schedule和scheduleAtFixedRate方法一般情况下是没什么区别的,只在某个情况出现时会有区别--当前任务没有来得及完成下次任务又交到手上. 我们来举个例子: 暑假到了老 ...

  7. spring报错NoClassDefFoundError等与第三方jar包导入问题

    今天配置spring,遇到各种报错的问题,做一个小小总结. 1.刚开始我忘了引入commons-logging,报错.--解决方式:下载并引入该jar包 2.spring以及commons-loggi ...

  8. 关于"设计模式“

    夜深了,人静了,该写点儿东西了.这是第一篇博客,写点儿对设计模式的粗浅理解吧.   什么是设计模式? 上学那会儿初次听到这个名字一点儿概念都没有,不知道它是用来干嘛的,感觉听上去挺抽象的一个东西. 工 ...

  9. 微软为啥让免费升Win10?

           今天终于赶在截止日期之前把我的联想PC升到win10.微软这次对中国开放的持续一年的免费升级活动主要有两个原因.首先当然是"感恩Windows用户长久支持的回馈".微 ...

  10. 将home多余的空间分配到"/"分区下

    一.操作过程 1.df -h 查看分区大小情况; [root@localhost /]# df -h Filesystem            Size  Used Avail Use% Mount ...