原题链接:
HDU-6164

大意:
给出一个平面镜围成的凸包,每个平面镜有一个反射衰减为 ki<0.9k_i 若射到平面镜缝隙则能量衰减至 0,给出每个平面镜的起点和终点(逆时针顺序),和入射的向量方向。入射能量为 1.0 ,求能量衰减到 1e-4 要经过多少次碰撞。

思路:
直接硬搞,由于 ki 有范围 可以求出最多不超过100次反射一定停止。
考虑到反射和判定线段跨立,比赛的时候写成直线的一般形式,写炸了,从标称整理出一些东西。

具体实现:

#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>#define MAXN 5000
#define eps 1e-9struct point
{double x,y;point(double a = 0,double b = 0){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(0,0),point b = point(0,0)){s = a; e = b;}
};point p[MAXN+5];
double c[MAXN+5];
int n;
point s[2];int sgn(double x)//判断正负
{if (x>eps) return 1;if (x<-eps) return -1;return 0;
}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);scanf("%d",&n);for (int i=0;i<n;i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&c[i]);p[n] = p[0];s[0] = point(0,0);scanf("%lf%lf",&s[1].x,&s[1].y);double now = 1.0;int ans = 0;bool flag = 1;point temp;point temp2;line l1,l2,l3,l4;while (now > 1e-4){ans++;for (int i=0;i<n;i++){if (!sgn((p[i]-s[0])^s[1]))//光线射到缝隙{now = 0;flag = 0;break;}}if (!flag) break;for (int i=0;i<n;i++){if (sgn((p[i]-s[0])^s[1]) >0 && sgn(s[1]^(p[i+1]-s[0]))>0)//由于是逆时针给方向{l1 = line(p[i+1],p[i]);l2 = line(s[0],s[1]+s[0]);temp = Get_Intersect(l1,l2);l3 = line(temp,point(p[i+1].y-p[i].y,p[i].x-p[i+1].x)+temp);l4 = line(s[0],point(p[i].x-p[i+1].x,p[i].y-p[i+1].y)+s[0]);temp2 = Get_Intersect(l3,l4);temp2 = 2*temp2-s[0];s[0] = temp;s[1] = temp2-s[0];now *= c[i];break;}}}printf("%d\n",ans);return 0;
}

多校9 HDU-6164 Dying Light 几何数学相关推荐

  1. 2017 多校3 hdu 6061 RXD and functions

    2017 多校3 hdu 6061 RXD and functions(FFT) 题意: 给一个函数\(f(x)=\sum_{i=0}^{n}c_i \cdot x^{i}\) 求\(g(x) = f ...

  2. 2017 多校2 hdu 6053 TrickGCD

    2017 多校2 hdu 6053 TrickGCD 题目: You are given an array \(A\) , and Zhu wants to know there are how ma ...

  3. HDU 1174 爆头(几何---叉积)

    爆头 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  4. 2017ACM暑期多校联合训练 - Team 7 1009 HDU 6128 Inverse of sum (数学计算)

    题目链接 Problem Description There are n nonnegative integers a1-n which are less than p. HazelFan wants ...

  5. the 12th UESTC Programming Contest Final Justice is Given by Light (几何+ 二分)

    题目来源: http://acm.uestc.edu.cn/#/problem/show/814 题意:是给你一堆凸包上的点,这些点会形成一个凸多边形,有两个god站在这个多边形上,他们可以释放一个半 ...

  6. 【杭电多校2020】Go Running【几何】【最小点覆盖】

    题意:有一个数轴,若干人在某个时刻开始从某个点朝某个方向按111的速度走若干时间.已知nnn个条件,形如tit_iti​时刻xix_ixi​的位置有人,求最少可能的人数. ∑n≤5×105\sum n ...

  7. HDU 3698-Let the light guide us(线段树+DP)愿圣光忽悠你

    题意: 给定两个矩阵,第一个矩阵代表时间,第二个矩阵代表距离.给出约束的公式,询问在每一行都造一个圣光塔最少花费多少时间! 思路: 对于题目中给的条件 |J-K| <=f[i][j] +f[i+ ...

  8. Rikka with Cake 【多校9 HDU 6681】【欧拉定理+扫描线】

    题目链接 题目大意 有一个蛋糕是一个矩形,一个顶点在(0,0)另一个顶点在(n,m),现在对这个蛋糕进行切割,上下左右四个方向切,问最后这个蛋糕有多少块 解题思路 首先这个题的一个结论是:块数=交点数 ...

  9. UVA10110 Light, more light【数学】

    There is man named "mabu" for switching on-off light in our University. He switches on-off ...

  10. 【几何/数学】概念的理解 —— (非)刚体变换((non-)rigid transformation)

    1. 刚体变换与非刚体变换 What is a non-rigid transformation? 刚体变换(rigid transformation)一般分为如下几种: 平移对象,而不改变形状和大小 ...

最新文章

  1. centos下nginx+postgresql+php+memcached+apc安装与配置
  2. tinycore Network card configuration during exec bootlocal.sh
  3. (仿头条APP项目)6.点击过的新闻列表文字变灰和下拉刷新与滚动加载新闻数据
  4. Tomcat无法访问中文路径的解决办法
  5. 信息核心技术体系是通往信息世纪的中国门票
  6. mysql 魔术设置_PHP之十六个魔术方法详细介绍
  7. IIS AppCreate子目录的错误(0x80020006)
  8. fedora 33 topbar_31省区市新增确诊33例,天津新增本地确诊1例
  9. 建设银行IT审计体系概况及实施策略
  10. 分享一个.NET(C#)按指定字母个数截断英文字符串的方法–提供枚举选项,可保留完整单词...
  11. ObjC学习8-重头戏来了!Foundation框架
  12. 池与线程池 技术点 目录 1. 线程池作用: 提升性能 1 2. 使用流程 1 3. 线程与线程池的监控 jvisual 1 4. 线程常用方法 2 5. 线程池相关概念 2 5.1. 队列
  13. Mybatis的生命周期及作用域
  14. 51定时器PWM调节
  15. php模仿一个开票系统,一个模仿oso的php论坛程序(之一)
  16. Java使文本框失去焦点的方法,使文本框失去焦点的事件是()A.ChangeB.FocusC.SetFocusD.LostFocus...
  17. Cannot Resolve Symbol xxx 错误解决
  18. 用计算机的画图工具画画,电脑绘画软件哪个好用?电脑绘画软件推荐
  19. Ethereum 入门
  20. 使用 GCD 实现倒计时效果

热门文章

  1. PLC上的数字的意思
  2. 实时频谱分析仪作下变频器的技术实现
  3. python电脑基础_python基础-1.计算机基础
  4. Linux中gcc的常用命令
  5. Pycharm新建文件时,如何设置自动添加作者时间等信息
  6. 相机内存卡照片删除怎么恢复
  7. oracle remote diagnostic agent,Oracle数据库收集、分析工具RDA(RemoteDiagnostic Agent)下载
  8. mysql修改my.ini_MySQL配置文件(my.ini)详解
  9. Linux在线词典问题,linux中goldendict发声词典播放报错问题解决方案
  10. 测向交叉定位matlab,测向交叉定位