• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

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

\epsfbox{p11880.eps}

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$ \le$L,W$ \le$109, 1$ \le$R$ \le$5, R$ \le$x$ \le$L - R, R$ \le$y$ \le$W - R, 0$ \le$a < 360, 1$ \le$v, s$ \le$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 }
View Code 2013-10-09 13:39:00

 

posted @ 2013-10-09 13:40  HaibaraAi  阅读(99)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3