Uva 11880 - Ball in a Rectangle
你为何这么叼!
标程简直丧心病狂!
Ball in a Rectangle
Time limit: 1.000 seconds
Input: Standard Input Output: Standard Output
� 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?
Input
There will be at most 25 test cases, each contains a line with 8 integers L,W,x,y,R,a,v,s (100
L,W
109, 1
R
5, R
x
L - R, R
y
W - R, 0
a < 360, 1
v, s
109), as stated above. The input terminates with L = W = x = y = R = a = v = s = 0, which should not be processed.
Output
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.
Sample Input
100 100 80 10 5 90 2 23 110 100 70 10 5 180 1 9999 0 0 0 0 0 0 0 0
Sample Output
80.00 56.00 71.00 10.00
Problemsetter: Rujia Liu, Special Thanks: Yiming Li, Shamim Hafiz & Sohel Hafiz
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <stdio.h> 3 #include <string.h> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 #include <set> 9 #include <map> 10 #include <string> 11 #include <math.h> 12 #include <stdlib.h> 13 #include <time.h> 14 using namespace std; 15 int n,m; 16 double l,w,s,a,v,x,y,r,t; 17 int main(){ 18 while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&l,&w,&x,&y,&r,&a,&v,&t)){ 19 if(l+w+x+y+r+a+v+t==0)break; 20 l-=2*r;w-=2*r;x-=r;y-=r;a*=acos(0.0)/90.0; 21 double dx=fmod(fmod(v*t*cos(a),2*l)+2*l,2*l); 22 double dy=fmod(fmod(v*t*sin(a),2*w)+2*w,2*w); 23 if(x+dx<=l)x+=dx;else if(x+dx<=2*l)x=l-(x+dx-l);else x=x+dx-2*l; 24 if(y+dy<=w)y+=dy;else if(y+dy<=2*w)y=w-(y+dy-w);else y=y+dy-2*w; 25 printf("%.2lf %.2lf\n",x+r,y+r); 26 } 27 return 0; 28 }
浙公网安备 33010602011771号