Pinball(物理)

                                                 Pinball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 616    Accepted Submission(s): 272


 

Problem Description

There is a slope on the 2D plane. The lowest point of the slope is at the origin. There is a small ball falling down above the slope. Your task is to find how many times the ball has been bounced on the slope.

It's guarantee that the ball will not reach the slope or ground or Y-axis with a distance of less than 1 from the origin. And the ball is elastic collision without energy loss. Gravity acceleration g=9.8m/s2.

 

 

Input

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 100), indicating the number of test cases.

The first line of each test case contains four integers a, b, x, y (1 ≤ a, b, -x, y ≤ 100), indicate that the slope will pass through the point(-a, b), the initial position of the ball is (x, y).

Output

Output the answer.

It's guarantee that the answer will not exceed 50.

Sample Input

 

1 5 1 -5 3

 

 

Sample Output

 

2

 

 

Source

2018 Multi-University Training Contest 6

解析:  这道题是物理题,模拟下运动轨迹,可知是类平抛运动,可以把斜面看成是水平面,速度分为与斜面水平和与斜面竖直两个方向,重力分为两个gx和gy两个力,在力的作用下,小球在斜面上做重力运动,上下跳动没有阻力,所以这个运动一直进行下去,在斜面上,小球做匀加速运动,直到落到水平面上一直做,因此可以算出小球在斜面上总的运动时间,和小球在竖直方向上上下一次运动的时间,就知道弹跳的次数了,

但是如果从小球落到斜面上再算的话,此时在斜面水平方向上已经有初速度,通过s=vt+1/2at^2这个公式,不好算时间,因此我们可以从降落点开始算时间t1就是在斜面水平方向上运动的时间,t2就是在竖直方向上下落一次的时间,最终(t1-t2)就是小球落到斜面上到(0,0)点用的时间,2*t2就是小球在竖直方向上一次弹跳(一上一下)的时间,

代码如下:

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define pi acos(-1)
#define g 9.8
int main()
{
    int T;
    double a,b,x,y;
    scanf("%d",&T);
    while(T--)
    {
        double t1,t2,h,s1,s2,gx,gy,c;
        scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
        x=-x;
        c=atan(b/a);
        gx=g*sin(c);
        gy=g*cos(c);
        h=y-x*tan(c);
        s1=x/cos(c)+h*sin(c);
        s2=h*cos(c);
        t1=sqrt(2*s1/gx);
        t2=sqrt(2*s2/gy);
        double sum=(t1-t2)/(2*t2);
        printf("%d\n",(int)sum+1);
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值