HDU6373 Pinball(2018HDU多校联赛第六场,物理)

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.
img

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

思路

给出一个斜坡和一个小球,小球自由落体向下运动,不考虑能量损失,问小球能在斜坡上反弹几次。

已知图上的 a,b,x,y a , b , x , y

首先把小球反弹后的速度进行分解,如下图

fantan.jpg

把速度分解成沿着斜坡方向和垂直于斜坡方向。

把重力加速度也分解成沿着斜坡方向和垂直于斜坡方向

那么我们就可以知道:

  • 水平方向: vx=vsinα=2ghsinα v x = v ∗ s i n α = 2 g h s i n α gx=gsinα g x = g s i n α
  • 垂直方向: vy=vcosα=2ghcosα v y = v ∗ c o s α = 2 g h c o s α gx=gcosα g x = g c o s α

因为小球下落到斜坡上和斜坡反弹小球到最高点用的时间是一样的,所以我们可以计算出小球碰撞两次所需要的时间,每一次小球在斜坡上反弹的时间都一样,那么这个过程就可以相当于把斜坡当成x轴把垂直于斜坡当成y轴,相当于一个小球在上面不听的反弹,但是又向右加速运动,我们利用每一次反弹的时间和速度就可以计算出位移比

t=2vygy=22ghcosαgcosα=22ghg t = 2 ∗ v y g y = 2 ∗ 2 g h ∗ c o s α g ∗ c o s α = 2 2 g h g

那么反弹一次的位移为:

x1=vxt+12gxt2=2ghsinα22ghg+12gsinα(22ghg)2=8hsinα x 1 = v x t + 1 2 g x t 2 = 2 g h ∗ s i n α ∗ 2 ∗ 2 g h g + 1 2 g s i n α ∗ ( 2 ∗ 2 g h g ) 2 = 8 h s i n α

第二次的速度为:

vx=vx+gxt=2ghsinα+gsinα22ghg=32ghsinα v x ′ = v x + g x t = 2 g h ∗ s i n α + g s i n α ∗ 2 ∗ 2 g h g = 3 2 g h ∗ s i n α

那么现在就可以推导出速度比: v1:v2:v3=1:3:5 v 1 : v 2 : v 3 = 1 : 3 : 5

位移比: x1:x2:x3=1:2:3 x 1 : x 2 : x 3 = 1 : 2 : 3

最后我们知道了位移比,我们只需要计算出斜面的长度按照比值向上加,知道大于斜坡长度时输出。

代码

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
const double pi=acos(-1.0);
const int N=1e5+10;
void solve()
{
    double a,b,x,y;
    scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
    double jiao=atan(b/a);
    double sina=sin(jiao);
    double h=y-b*(-x)/a;
    double L=(y-h)/sina;
    int ans=0,sum=0;
    for(int i=1; i<=50; i++)
    {
        ans++;
        sum+=i;
        if((double)sum*8.0*h*sina>L)
        {
            printf("%d\n",ans);
            break;
        }
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)solve();
    return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值