Elastic Ball in the Frame(水题)

来源:互联网 发布:cpda数据分析师 含金量 编辑:程序博客网 时间:2024/05/16 09:35

1463: Elastic Ball in the Frame

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 249  Solved: 72
[Submit][Status][Web Board]

Description

In a rectangular frame, there’s an elastic ball which can be regarded as a mass point(The ball can make elastic collisions with the frame).The frame lies on a smooth horizontal plane, and the initial position of the ball is at the lower left quarter(左下角)of the frame. Taking horizontal border as x axis and the vertical border as y axis, we can build the coordinate(坐标系). The position of the ball is (0,0).Given the ball’s initial speed, you are supposed to find its position at time t. (The collision trace of the ball forms a mirror reflection.)

Input

There is a positive integer n(n<1000) on the first line, representing the case number. There follows n lines, each line has 5 positive rational number, v(0<v<100), a(0<a<90), l(0<l<100), d(0<d<100),t(0<t<107),representing the ball’s initial speed, the intersection angle between the ball’s initial speed and the x axis, the length of the vertical border, the length of the horizontal border, and the queried time respectively.

Output

For each case, output the corresponding position in the (x,y) form, keeping two decimal places.

Sample Input

21 45 2 2 21 53.13 4 6 10

Sample Output

(1.41,1.41)(6.00,0.00)

HINT


Sample 1 and sample 2 are shown below. 




题意:在矩形框架中,有一个弹性球可以被认为是一个质点(球可以与框架弹性碰撞)。框架位于平滑的水平面上,球的初始位置在左下方(左下角)。将水平边框作为x轴和垂直边框作为y轴,我们可以构建坐标系(坐标系)。球的位置是(0,0)。根据球的初始速度,你应该在时间t找到它的位置。(球的碰撞轨迹形成镜面反射。)

#include <algorithm>#include <iostream>#include <cstdio>#include <cmath>#include <cstring>using namespace std;const double PI = atan(1)*4;double judge(double x,double r){    int xans=(int)(x/(2*r));    x=x-r*2*xans;    if(x>r)        x=r-(x-r);    return x;}int main(){    int T;    scanf("%d",&T);    while(T--) {        double x,v,a,l,d,t,xx,yy,vx,vy;        scanf("%lf%lf%lf%lf%lf",&v,&a,&l,&d,&t);        x=v*t;        xx=x*cos(a*PI/180);//转换成角度        xx=judge(xx,d);        yy=x*sin(a*PI/180);        yy=judge(yy,l);        printf("(%.2lf,%.2lf)\n",xx,yy);    }    return 0;}



1463: Elastic Ball in the Frame

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 249  Solved: 72
[Submit][Status][Web Board]

Description

In a rectangular frame, there’s an elastic ball which can be regarded as a mass point(The ball can make elastic collisions with the frame).The frame lies on a smooth horizontal plane, and the initial position of the ball is at the lower left quarter(左下角)of the frame. Taking horizontal border as x axis and the vertical border as y axis, we can build the coordinate(坐标系). The position of the ball is (0,0).Given the ball’s initial speed, you are supposed to find its position at time t. (The collision trace of the ball forms a mirror reflection.)

Input

There is a positive integer n(n<1000) on the first line, representing the case number. There follows n lines, each line has 5 positive rational number, v(0<v<100), a(0<a<90), l(0<l<100), d(0<d<100),t(0<t<107),representing the ball’s initial speed, the intersection angle between the ball’s initial speed and the x axis, the length of the vertical border, the length of the horizontal border, and the queried time respectively.

Output

For each case, output the corresponding position in the (x,y) form, keeping two decimal places.

Sample Input

21 45 2 2 21 53.13 4 6 10

Sample Output

(1.41,1.41)(6.00,0.00)

HINT


Sample 1 and sample 2 are shown below. 



 

Source

原创粉丝点击