HDU5572 An Easy Physics Problem 【计算几何】
来源:互联网 发布:apache ant 1.9.3下载 编辑:程序博客网 时间:2024/06/05 18:19
An Easy Physics ProblemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2113 Accepted Submission(s): 410Problem DescriptionOn an infinite smooth table, there's a big round fixed cylinder and a little ball whose volume can be ignored.Currently the ball stands still at point A, then we'll give it an initial speed and a direction. If the ball hits the cylinder, it will bounce back with no energy losses.We're just curious about whether the ball will pass point B after some time.InputFirst line contains an integer T, which indicates the number of test cases.Every test case contains three lines.The first line contains three integers Ox, Oy and r, indicating the center of cylinder is (Ox,Oy) and its radius is r.The second line contains four integers Ax, Ay, Vx and Vy, indicating the coordinate of A is (Ax,Ay) and the initial direction vector is (Vx,Vy).The last line contains two integers Bx and By, indicating the coordinate of point B is (Bx,By).⋅ 1 ≤ T ≤ 100.⋅ |Ox|,|Oy|≤ 1000. ⋅ 1 ≤ r ≤ 100.⋅ |Ax|,|Ay|,|Bx|,|By|≤ 1000. ⋅ |Vx|,|Vy|≤ 1000.⋅ Vx≠0 or Vy≠0.⋅ both A and B are outside of the cylinder and they are not at same position.OutputFor every test case, you should output "Case #x: y", where x indicates the case number and counts from 1. y is "Yes" if the ball will pass point B after some time, otherwise y is "No".Sample Input20 0 12 2 0 1-1 -10 0 1-1 2 1 -11 2Sample OutputCase #1: NoCase #2: YesSource2015ACM/ICPC亚洲区上海站-重现赛(感谢华东理工)
情况有好几种
如果将整个图旋转一下 ,让
当A能射中B:
①A直接射到B上:
这种情况
②A射到圆上,且沿着反方向反弹,射中B
other:
#include<iostream>#include<stdlib.h>#include<stdio.h>#include<string>#include<vector>#include<deque>#include<queue>#include<algorithm>#include<set>#include<map>#include<stack>#include<time.h>#include<math.h>#include<list>#include<cstring>#include<fstream>#include<queue>#include<sstream>//#include<memory.h>using namespace std;#define ll long long#define ull unsigned long long#define pii pair<int,int>#define INF 1000000007#define pll pair<ll,ll>#define pid pair<int,double>const int inf=1e9+7;const double EPS=1e-7;struct P{ double x,y; double operator*(const P&p){//点乘 double ans=x*p.x+y*p.y; return ans; } double crossProd(const P&p){//叉乘 return x*p.y-y*p.x; } double mod(){ return sqrt(x*x+y*y); } void roate(double angle){//逆时针旋转angle度 angle=x*PI double tx=x*cos(angle)-y*sin(angle); double ty=y*cos(angle)+x*sin(angle); x=tx; y=ty; } double distance(const P&p){ double tmp=(p.x-x)*(p.x-x)+(p.y-y)*(p.y-y); return sqrt(tmp); }}a,b,o,v;istream&operator>>(istream&in,P&p){ in>>p.x>>p.y; return in;}int r;bool slove(){ P vec={1,0}; double cosVal=vec*v/(vec.mod()*v.mod()); double angle=acos(cosVal); if(v.crossProd(vec)<EPS){ angle=-angle; } a.roate(angle); b.roate(angle); o.roate(angle); if(fabs(a.y-b.y)<EPS){ if(b.x<a.x){ if(o.x>a.x&&fabs(o.y-a.y)<EPS){ return true; } return false; } if(a.x<=o.x&&o.x<=b.x){ if(o.y-r<=a.y+EPS&&a.y<=o.y+r+EPS){ return false; } } return true; } double ta=1; double tb=-2.0*o.x; double tc=o.x*o.x+a.y*a.y-2*o.y*a.y+o.y*o.y-r*r; double dt=tb*tb-4.0*ta*tc; if(dt<0){ return false; } P c; c.x=(-tb-sqrt(dt))/(2.0*ta); c.y=a.y; double k_co=(c.y-o.y)/(c.x-o.x); double k=-1.0/k_co; double dis=b.distance(c); P d; d.x=c.x+dis; d.y=c.y; P mid={(b.x+d.x)/2.0,(b.y+d.y)/2.0}; return fabs(mid.y-c.y-k*(mid.x-c.x))<EPS;}int main(){ //freopen("/home/lu/Documents/r.txt","r",stdin); //freopen("/home/lu/Documents/w.txt","w",stdout); int T; scanf("%d",&T); for(int t=1;t<=T;++t){ cin>>o>>r>>a>>v>>b; printf("Case #%d: %s\n",t,slove()?"Yes":"No"); } return 0;}
0 0
- HDU5572 An Easy Physics Problem 【计算几何】
- HDU 5572 An Easy Physics Problem【计算几何】
- HDU 5572 An Easy Physics Problem (物理、计算几何)
- HDU 5572 An Easy Physics Problem (计算几何+模板)
- HDU 5572-An Easy Physics Problem (计算几何)
- hdu5572An Easy Physics Problem+计算几何
- An Easy Physics Problem (hdu5572) 2015ACM/ICPC亚洲区上海站
- An Easy Physics Problem
- hdu 5572 An Easy Physics Problem(几何)
- [POJ2826] An Easy Problem?! && 计算几何
- POJ 2826 An Easy Problem?!(计算几何)
- POJ 2826 An Easy Problem?!(计算几何)
- [POJ2826]An Easy Problem?!(计算几何)
- POJ 2826 An Easy Problem 计算几何
- [POJ2826]An Easy Problem?!(计算几何)
- POJ 2826 An Easy Problem?! <计算几何>
- An Easy Problem?! POJ 2826 计算几何
- HDU 5572 An Easy Physics Problem(计算几何)——2015ACM/ICPC亚洲区上海站-重现赛
- 模仿读取struts.xml TDD重写
- 开通大吉
- jquery基础语法
- android逆向常用工具
- windows下安装docker
- HDU5572 An Easy Physics Problem 【计算几何】
- spring boot 中@Autowired注解无法自动注入的错误
- ubuntu下终端提示符颜色配置以及git分支配置
- 文件分离
- 关于做梦
- 如何通过会声会影制作视频影片
- 创建文件夹 并 实现文件(夹)拷贝
- 调试provider的代码时候,粗心的错误
- sql 多个排序选择,与它的坑