题意:有n个灯,每个灯有一个照亮的角度,现在从点(l,0)走到点(r,0),问这个人若一直被灯照着能最多走多远?

思路;状压dp,然后通过向量旋转求出点(dp[i[,0)与灯的坐标(p[j].x,p[j].y)形成的向量然后旋转角度p[j].a,得到旋转之后的在x坐标轴上的点,然后与dp[i|(1<<j)]比较更新,找出最大值,再与右端点比较。有个情况,在旋转向量时,可能不与坐标轴有交点,你就把dp[i|(1<<j)]=r;

 #include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
const double pi=acos(-1.0); int n;
double l,r;
struct node
{
double x,y;
double a;
}p[];
double dp[(<<)+]; int main()
{
while(scanf("%d%lf%lf",&n,&l,&r)!=EOF)
{
for(int i=; i<n; i++)
{
double aa;
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&aa);
p[i].a=(double)(aa*1.0*pi/);
}
for(int i=; i<(<<n); i++) dp[i]=l;
double ans=l;
for(int i=; i<(<<n); i++)
{
ans=max(ans,dp[i]);
for(int j=; j<n; j++)
{
if((i&(<<j))==)
{
double xx=dp[i]-p[j].x;
double yy=-p[j].y;
double x1=xx*cos(p[j].a)-yy*sin(p[j].a);
double y1=xx*sin(p[j].a)+yy*cos(p[j].a);
double sx=p[j].x+yy*(x1*1.0/y1);
if(sx>r) sx=r;
if(y1>=)
{
dp[i|(<<j)]=r;
continue;
}
dp[i|(<<j)]=max(dp[i|(<<j)],sx);
}
}
}
printf("%.10lf\n",min(ans,r)-l);
}
return ;
}

cf D Bear and Floodlight的更多相关文章

  1. CF 628C --- Bear and String Distance --- 简单贪心

    CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符 ...

  2. Bear and Floodlight 状态压缩DP啊

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

  3. Codeforces 385D - Bear and Floodlight

    385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai ...

  4. cf B Bear and Strings

    题意:给你一个字符串,然后找多少区间内含有“bear”,输出数目: #include <cstdio> #include <cstring> #include <algo ...

  5. cf C Bear and Prime Numbers

    题意:给你一个n,输入n个数,然后输入m,接下来有m个询问,每一个询问为[l,r],然后输出在区间内[l,r]内f(p)的和,p为[l,r]的素数,f(p)的含义为在n个数中是p的倍数的个数. 思路: ...

  6. CodeForces 385 D.Bear and Floodlight 状压DP

    枚举灯的所有可能状态(亮或者不亮)(1<<20)最多可能的情况有1048576种 dp[i]表示 i 状态时灯所能照射到的最远距离(i 的二进制中如果第j位为0,则表示第j个灯不亮,否则就 ...

  7. 【计算几何】【状压dp】Codeforces Round #226 (Div. 2) D. Bear and Floodlight

    读懂题意发现是傻逼状压. 只要会向量旋转,以及直线求交点坐标就行了.(验证了我这俩板子都没毛病) 细节蛮多. #include<cstdio> #include<algorithm& ...

  8. Codeforces 385 D Bear and Floodlight

    主题链接~~> 做题情绪:时候最后有点蛋疼了,处理点的坐标处理晕了.so~比赛完清醒了一下就AC了. 解题思路: 状态压缩DP ,仅仅有 20 个点.假设安排灯的时候仅仅有顺序不同的问题.全然能 ...

  9. 牛客 545A 小A与最大子段和 & CF 660F Bear and Bowling 4

    大意: 给定序列$a$, 求选择一个子区间$[l,r]$, 使得$\sum\limits_{i=l}^r(i-l+1)a_i$最大. $n\le2e5, |a_i|\le 1e7$. 记$s[i]=\ ...

随机推荐

  1. jquery+正則表達式验证邮箱格式的样例

    js: $("#email").blur(function(){ //获取id相应的元素的值,去掉其左右的空格 var email = $.trim($('#email').val ...

  2. [RxJS] Filtering operator: filter

    This lesson introduces filter: an operator that allows us to let only certain events pass, while ign ...

  3. [RxJS] Aggregating Streams With Reduce And Scan using RxJS

    What is the RxJS equivalent of Array reduce? What if I want to emit my reduced or aggregated value a ...

  4. MapReduce分析明星微博数据

    互联网时代的到来,使得名人的形象变得更加鲜活,也拉近了明星和粉丝之间的距离.歌星.影星.体育明星.作家等名人通过互联网能够轻易实现和粉丝的互动,赚钱也变得前所未有的简单.同时,互联网的飞速发展本身也造 ...

  5. Enable Access Logs in JBoss 7 and tomcat--转

    JBoss 7 is slightly different than earlier version JBoss 5 or 6. The procedure to enable access logs ...

  6. PHP中的循环while、do...while、for、foreach四种循环。

    php中的while循环,循环执行代码块制定的次数,或者当指定的条件为真时循环执行代码块. 在我们编写代码是时候,我们经常需要一块代码块重复执行多次.我们就可以使用while循环语句来完成这个任务. ...

  7. Java 原始数据类型转换

    在开发中经常遇到数据类型转换的问题,大多数都是拿来强制转换,强制转换可能会出现你意想不到的问题: int a = -1; 我们经过多重转换之后:int b = (int)(char)(byte) a ...

  8. dedecms 5.7文章编辑器附件上传图标不显示

    我最近发现在使用dedecms 5.7文章编辑器附件上传图标不显示了,以前是没有问题的,这个更新系统就出来问题了,下面我来给大家分享此问题解决办法.   问题bug:在dedecms 5.7中发现了一 ...

  9. 关键词:CodeSmith工具、Money类型、__UNKNOWN__

    问题描述: 当数据库列类型有Money类型的时候,CodeSmith生成数据访问层会出错.有不能识别的类型.解决方法: 通过查找资料得知,数据库中的Money类型在DbType中是Currency(货 ...

  10. sql数值显示成千分位分隔符的形式

    ), )--带小数点 ), ),'.00','')--不带小数点