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. 解决win7中防火墙的0x6D9问题的方法

    问题: 打开windows防火墙管理单元时出错:代码0x6d9" 解决方法: 下一步-->下一步-->完成.

  2. web基础笔记整理(一)

    一.程序的分层 1.界面层: 某种类型的应用程序 a.DOS(控制台运行) b.桌面应用程序--独立安装,独立运行 c.web类型--现在流行的 单机版:电脑上要安装,程序升级之后,电脑上也要升级-- ...

  3. Java 哲学家进餐

    某次操作系统实验存档.V 这个哲学家除了吃就知道睡.( ╯□╰ ) 哲学家.java: package operating.entity.philosophyeating; import operat ...

  4. 视觉SLAM中相机详解

    视觉SLAM中,通常是指使用相机来解决定位和建图问题. SLAM中使用的相机往往更加简单,不携带昂贵的镜头,以一定的速率拍摄周围的环境,形成一个连续的视频流. 相机分类: 单目相机:只是用一个摄像头进 ...

  5. Docker(十三):OpenStack部署Docker集群

    1.介绍 本教程使用Compose.Machine.Swarm工具把WordPress部署在OpenStack上. 本节采用Consul作为Swarm的Discovery Service模块,要利用C ...

  6. rm 命令详解

    rm  作用: 删除一个目录中的一个或多个文件或目录,也可以将某个目录及下属的所有文件及子目录均删除掉, 对于连接文件只是删除整个连接文件,而保持原有文件. 注意: 使用rm 命令要格外小心,因为一旦 ...

  7. Java 多线程笔记

    资料来源于网络,仅供参考学习.   1.A Java program ends when all its threads finish (more specifically, when all its ...

  8. hashCode花式卖萌

    声明:这篇博文纯属是最近看源码时闲着没事瞎折腾(好奇心驱动),对实际的应用程序编码我觉得可能没有那么大的帮助,各位亲就当是代码写累了放松放松心情,视为偏门小故事看一看就可以了,别深究. 一.从Obje ...

  9. 在QLabel上同时显示文字和图片的方法

    有两种方法. 1.打开UI文件,在界面右键单击QLabel对象,选改变多信息文本 选择图片再确定,左侧问号就是图片. 2.直接在QLabel写富文本 <html><head/> ...

  10. 响应式布局—设备像素密度测试 (-webkit-min-device-pixel-ratio)

      最近遇到这种头疼的问题,百思不得其解,不耻下问,悬梁刺股这些事情都做过之后,终于看到希望,于是攒见好就收,感觉整理分享给大家,希望有所帮助. 对手机分辨率和网页像素的初步认识是,是2倍的差别. 但 ...