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. C# 委托高级应用----线程——创建无阻塞的异步调用(一)

    前言 本文大部分内容来自于mikeperetz的Asynchronous Method Invocation及本人的一些个人体会所得,希望对你有所帮助.原英文文献可以在codeproject中搜索到. ...

  2. OC学习8——异常处理

    1.和Java一样,OC也有自己的一套异常处理机制,不同的是,OC中的异常处理机制并不是作为常规的编程实践,通常只是作为一种程序调试.排错机制. 2.与Java中类似,OC中也是采用@try...@c ...

  3. iOS 类似朋友圈的图片浏览器SDPhotoBrowser

    SDPhotoBrowser.Demo 1.在文件SDBrowserImageView.m中有用SDWebImage到网络加载图片 需要的注释去掉即可 #import "ViewContro ...

  4. CPU31X-2DP通过DP网络连接远程IO站

    一.远程IO站介绍 二.该DP网络系统结构 三.组态DP主站 1.组态机架硬件配置 2.设置profibus属性,主站地址为2,如下图 3.完成主站组态 四.组态远程IO从站ET200M 1.接口模块 ...

  5. iView的使用【CDN向】

    直接粗暴地上html代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  6. php-fpm开机启动

    php-fpm开机自动启动脚本 网上有各种版本的php-fpm开机自动启动脚本, 其实你编译后源目录已经生成自动脚本.不用做任何修改即用. cp {php-5.3.x-source-dir}/sapi ...

  7. Docker了解

    Docker了解1.Docker能做什么:Docker能够解决虚拟机能够解决的问题,同时也能够解决虚拟机由于请求资源过高无法解决的问题. *隔离应用依赖 *创建应用镜像并进行复制 *创建容易分发的即启 ...

  8. Linux第八讲随笔 -tar / 系统启动流程

    linux 第八讲1.tar 参考 作用:压缩和解压文件.tar本身不具有压缩功能.他是调用压缩功能实现的. 语法:tar[必要参数][选择参数][文件] 参数:必要参数有如下: -A 新增压缩文件到 ...

  9. php运行C++程序

    linux命令:gcc hello.cpp -lstdc++ -o hello.o php代码: <?php $command="./hello.o "; passthru( ...

  10. jquery 怎么判断当前按钮是否是disabled 属性

    https://zhidao.baidu.com/question/1733097469792964827.html 应该用 prop("disabled") 有则返回true吧? ...