题意:有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. 使用r2d3的注意事项

    避免使用tspan 样式上display:none无效, visibility:hidden无效,只能使用fill:none或rgba(0,0,0,0) 容器不能起到绘图的层级作用,覆盖顺序由先后顺序 ...

  2. 使用strace追踪多个进程

    http://www.ttlsa.com/tools/use-strace-to-track-multiple-processes/  strace是Linux环境下的一款程序调试工具,用来监察一个应 ...

  3. java Map实现的cache manager

    一个模仿memcached的JAVA虚拟缓存工具,可以缓存java对象 import java.io.ByteArrayInputStream; import java.io.ByteArrayOut ...

  4. [转] Initial Impressions on GraphQL & Relay

    https://kadira.io/blog/graphql/initial-impression-on-relay-and-graphql http://graphql.org/blog/subsc ...

  5. Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

    How do I increase the maximum number of open files under CentOS Linux? How do I open more file descr ...

  6. oracle 字符串切割成结果集方法

    oracle字符串切割几种方式 方法一: SELECT COLUMN_VALUE FROM TABLE(SYS.ODCIVARCHAR2LIST('1','2','3','4','5')); 方法二: ...

  7. 详细分析Orchard的Content、Drivers, Shapes and Placement 类型

    本文原文来自:http://skywalkersoftwaredevelopment.net/blog/a-closer-look-at-content-types-drivers-shapes-an ...

  8. android 利用隐式Intent打开图片

    实现功能   点击"查看图片"时能够跳出提示,选择系统图库打开还是自己编写的应用打开,并且对于下载好的图片也有效. 1.我将 qiaoba.jpg 放在 res/drawable  ...

  9. 用PHP实现一个高效安全的ftp服务器(二)

    接前文. 1.实现用户类CUser. 用户的存储采用文本形式,将用户数组进行json编码. 用户文件格式: * array( * 'user1' => array( * 'pass'=>' ...

  10. java开发规范总结_命名规范

    规范需要平时编码过程中注意,是一个慢慢养成的好习惯 1.文件 1.属性文件后缀为properties,并且符合java中i18n的规范:   2.对于各产品模块自己的配置文件必须放置在自己模块的con ...