Dying Light

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 513    Accepted Submission(s): 122

Problem Description

LsF
is visiting a local amusement park with his friends, and a mirror room
successfully attracts his attention. Inside the mirror room, there are n
plane mirrors standing vertically on the ground. They are placed
end-to-end and face-to-face so that if you overlook the room, you can
find a convex hull and the all the reflector surfaces are inside the
pattern. The height of the mirror is not important in this problem.
Due
to imperfect manufacturing techniques, mirrors can't reflect light
without lose of energy. Each mirror has a reflection efficiency k, which
means if the incident light's intensity is I, the reflected light's
intensity will be reduced to kI. The only exception could happen when
the light precisely goes to the two mirrors' junction. In that case, the
light will be completely absorbed instantly. Note the laws of
reflection of light applies in all other situations, that the angle of
incidence equals the angle of reflection.
Now LsF stands inside the
mirror hall, and shoots a laser beam paralleled to the ground using his
laser pointer. Unfortunately, his laser pointer can only shot laser
beams with intensity of 1. What's worse, a laser beam is considered
disappeared if its intensity is below 10−4. There's not much magnitude distance between the two numbers.
LsF wants to know how many touches can his laser beam make with mirrors before it disappears.
 
Input
The first line contains an integer n(3≤n≤1000), indicating the number of mirrors;
Then n lines follow. The ith line contains three real numbers xi,yi,ki(−109≤xi,yi≤109;0≤ki≤0.9), which means the ith mirror's one end is at position (xi,yi) and another end is at (xi+1mod n,yi+1mod n), and its reflectivity is ki.
Next there are two real numbers Vx,Vy(-109≤Vx,Vy≤109), indicating the initial direction vector of the laser beam.
LsF is standing at the origin (0, 0).

 
Output
Output an integer in one line, the number of touches the laser beam could make before it disappears.
 
Sample Input
4
1 2 0.5
-1 0 0.5
1 -2 0.5
3 0 0.5
0 1
4
1 1 0.5
-1 1 0.5
-1 -1 0.5
1 -1 0.5
1 1
Sample Output
14
1
Source
分析:由于LsF一开始不再镜子上,按题面模拟即可。
由于反射率<=0.9 0.9^100<1e-4,所以反射次数不会超过100次。
每次暴力判断和哪个镜子相交,以及有没有在镜子焦点上。
下面给出AC代码:
 #include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream> #define MAXN 5000
#define eps 1e-9 struct point
{
double x,y;
point(double a = ,double b = )
{
x = a; y = b;
}
friend point operator + (point a,point b)
{
return point(a.x+b.x,a.y+b.y);
}
friend point operator - (point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
friend double operator ^ (point a,point b)
{
return a.x*b.y-a.y*b.x;
}
friend double operator * (point a,point b)
{
return a.x*b.x+a.y*b.y;
}
friend point operator * (point a,double b)
{
return point(a.x*b,a.y*b);
}
friend point operator * (double a,point b)
{
return point(a*b.x,a*b.y);
} }; struct line
{
point s,e;
line(point a = point(,),point b = point(,))
{
s = a; e = b;
}
}; point p[MAXN+];
double c[MAXN+];
int n;
point s[]; int sgn(double x)
{
if (x>eps) return ;
if (x<-eps) return -;
return ;
} point Get_Intersect(line a,line b)
{
double u=(a.e-a.s)^(b.s-a.s);
double v=(a.s-a.e)^(b.e-a.e);
point p;
p.x=(b.s.x*v+b.e.x*u)/(v+u);
p.y=(b.s.y*v+b.e.y*u)/(v+u);
return p;
} int main()
{
// freopen("input.txt","r",stdin);
while(scanf("%d",&n)!=EOF)
{for (int i=;i<n;i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&c[i]);
p[n] = p[];
s[] = point(,);
scanf("%lf%lf",&s[].x,&s[].y); double now = 1.0;
int ans = ;
bool flag = ;
point temp;
point temp2;
line l1,l2,l3,l4;
while (now > 1e-)
{
ans++;
for (int i=;i<n;i++)
{
if (!sgn((p[i]-s[])^s[]))
{
now = ;
flag = ;
break;
}
}
if (!flag) break;
for (int i=;i<n;i++)
{
if (sgn((p[i]-s[])^s[]) > && sgn(s[]^(p[i+]-s[]))>)
{
l1 = line(p[i+],p[i]);
l2 = line(s[],s[]+s[]);
temp = Get_Intersect(l1,l2); l3 = line(temp,point(p[i+].y-p[i].y,p[i].x-p[i+].x)+temp);
l4 = line(s[],point(p[i].x-p[i+].x,p[i].y-p[i+].y)+s[]); temp2 = Get_Intersect(l3,l4);
temp2 = *temp2-s[];
s[] = temp;
s[] = temp2-s[];
now *= c[i];
break;
}
}
}
printf("%d\n",ans);
}
return ;
}

2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】的更多相关文章

  1. 2017 Multi-University Training Contest - Team 1 1002&&hdu 6034

    Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  2. 2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】

    FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. 2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】

    CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  4. 2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】

    Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  5. 2017 Multi-University Training Contest - Team 9 1001&&HDU 6161 Big binary tree【树形dp+hash】

    Big binary tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  6. 2017 Multi-University Training Contest - Team 1 1003&&HDU 6035 Colorful Tree【树形dp】

    Colorful Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  7. 2017 Multi-University Training Contest - Team 1 1006&&HDU 6038 Function【DFS+数论】

    Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  8. 2017 Multi-University Training Contest - Team 1 1002&&HDU 6034 Balala Power!【字符串,贪心+排序】

    Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  9. 2017 Multi-University Training Contest - Team 1 1011&&HDU 6043 KazaQ's Socks【规律题,数学,水】

    KazaQ's Socks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

随机推荐

  1. Spark源码剖析(一):如何将spark源码导入到IDEA中

    由于近期准备深入研究一下Spark的核心源码,所以开了这一系列用来记录自己研究spark源码的过程! 想要读源码,那么第一步肯定导入spark源码啦(笔者使用的是IntelliJ IDEA),在网上找 ...

  2. geoserver安装部署步骤

    方式一:直接在geoserver官网下载zip源代码解压包,直接部署在tomcat里面运行geoserver: 方式二:下载安装包方式 以GeoServer2.8.5版本为准,安装之前必须要保证你机子 ...

  3. open-falcon(v0.2)部署手册(源码编译)

    今天安装falcon-plus,下面为用基础环境配置. centos 6.8  alisql5.6.32   redis-3.2.8 cmake-3.9.1 bison-3.0 openssl-1.0 ...

  4. vue2 vue-rout

    vue 2.0的路由比起1.0简单了许多,分为以下几个步骤: 1.创建路由块和视图块: to里面是要切换的路径名称 <div id="app"> <div> ...

  5. jsDOM编程-拖拽层

    页面样式代码: <!doctype html><html><head><meta http-equiv="content-type" co ...

  6. 全国交通咨询系统 by C++ on Linux

    信息存储 利用邻接表存储城市信息与线路信息,比邻接矩阵更加高效. 主要数据结构 I)Time,规范时间的输入输出格式 II)VNode,头结点,用于建立顶点表,存储城市信息 III)ArcNode,表 ...

  7. springBoot系列教程07:异常捕获

    发生异常是很正常的事,异常种类也是千奇百怪,发生异常并不可怕,只要正确的处理,并正确的返回错误信息并无大碍,如果不进行捕获或者处理,分分钟服务器宕机是很正常的事 所以处理异常时,最基本的要求就是发生异 ...

  8. QA问答系统,QA匹配论文学习笔记

    论文题目: WIKIQA: A Challenge Dataset for Open-Domain Question Answering 论文代码运行: 首先按照readme中的提示安装需要的部分 遇 ...

  9. Android真机安装sqlite3的方法

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  10. java多线程(六)-线程的状态和常用的方法

    一个线程可以处于以下几种状态之一: (1) 新建(new):当线程被创建时,它只会短暂的处于这种状态,此时它已经获得了必须的系统资源,并执行了初始化,该线程已经有资格获取cpu时间了,之后它将转化为可 ...