toj 4608 Ball in a Rectangle
来源:互联网 发布:ojbdk是什么意思网络 编辑:程序博客网 时间:2024/05/17 14:25
toj 4608 Ball in a Rectangle
时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte
总提交: 26 测试通过:16
描述
There is a rectangle on the cartesian plane, with bottom-left corner at (0,0) and top-right corner at (L, W). There is a ball centered at (x, y), with radius=R, shown below
At time 0, the ball starts to move along a ray with polar angle a (the angle from positive x-axis to the ray, rotating counter-clockwise). When hitting the rectangle boundary, the reflex angle always equals to the incidence angle. The ball’s velocity is always v (i.e. it never changes when hitting the rectangle). Where is the center of the ball at time s?
输入
There will be at most 25 test cases, each contains a line with 8 integers L,W,x,y,R,a,v,s (100
输出
For each test case, output a line containing two floating-point numbers x, y, rounded to two decimal points, indicating that the center of ball will be at (x, y) at time s.
样例输入
100 100 80 10 5 90 2 23
110 100 70 10 5 180 1 9999
0 0 0 0 0 0 0 0
样例输出
80.00 56.00
71.00 10.00
//矢量分解#include <iostream>#include <cstdio>#include <cmath>using namespace std;double l,w,x,y,r,a,v,s;int main(){ while(cin>>l>>w>>x>>y>>r>>a>>v>>s) { if(!l&&!w&&!x&&!y&&!r&&!a&&!v&&!s) break; l-=2*r;w-=2*r; x-=r;y-=r;//相应坐标也要变换 a=a*acos(0.0)/90; double vx=v*cos(a),vy=v*sin(a); double dx=fmod(fmod(vx*s,2*l)+2*l,2*l);//其实包括了两部分,向正方向和向负方向,为了code的方便,把两种情况统一为向正方向。 //fmod(vx*s,2*l)如果为负值,说明是向着负方向走i米,也就相当于向着正方向走了(2*l-i)米 double dy=fmod(fmod(vy*s,2*w)+2*w,2*w); if(x+dx<=l) x+=dx;//分三种情况讨论 else if(x+dx<=2*l) x=l-(x+dx-l); else x=x+dx-2*l; if(y+dy<=w) y+=dy; else if(y+dy<=2*w) y=w-(y+dy-w); else y=y+dy-2*w; printf("%.2lf %.2lf\n",x+r,y+r); } return 0;}
- toj 4608 Ball in a Rectangle
- UVA11880 Ball in a Rectangle
- UVA 11880 (Ball in a Rectangle) 平面几何
- UVA 11880 Ball in a Rectangle 几何
- uva 11880 Ball in a Rectangle(计算几何)
- Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- hdu1506Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- HDU1506_Largest Rectangle in a Histogram
- hdu1506Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- POJ2559Largest Rectangle in a Histogram
- hdu_1507_Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- Largest Rectangle in a Histogram
- iOS 对数组中的对象进行排序
- 初学HTML5--CSS样式(四)
- HDOJ 1231 最大连续子序列
- 123
- Java反射第二课 动态加载类
- toj 4608 Ball in a Rectangle
- eclipse开发环境搭建
- 同步和互斥的关系
- 前端模块化开发的价值
- jQuery-1.8.3文件和CDN加速地址
- 发布:dubboPlus - 支持thrift原生协议(dubbo扩展)
- 位操作
- 2016.8.9 练习全部精简的切换
- usb alternate settings