HDU6373 Pinball(羞愧,你懂的)

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

分析:一道物理题,关键是还推错了关系。羞愧.呜呜呜。

接下来我们就分析一下这道物理题。题目啦啦啦就两点;

1.求撞击斜面的次数

2.到原点距离小于1时不会再撞击斜面。

如何来做这道题呢?

首先受力分析。。。不考虑动能损失,重力做功。因而我们可以把加速度分解为平行于斜面和垂直于斜面两部分。

话说为啥子这样分解呢。我们来看看它们的作用。

1.垂直于斜面的加速度:我们阔以知道小球摊到最高点锤形斜面方向速度为0,和到撞击斜面时的速度相同,我们就知道了运动的时间。

2.平行于斜面的加速度。更新平行斜面的速度以及求运动距离。有了运动距离。只要保证他到原点的距离大于1求他撞击次数即可。

AC代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int a, b, x, y;
double sinu, cosu, tanu, vy, vx, v, h,d,t,gy,gx;
const double g = 9.8;
int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d%d%d%d", &a, &b, &x, &y);
		a = abs(a);
		x = abs(x);//直接把他干到第一象限省的麻烦。
		sinu = double(b) / sqrt(double(a*a) + double(b * b));
		cosu = double(a) / sqrt(double(a*a) + double(b * b));
		tanu = double(b) / double(a);
		//求出sin,cos,tan的值便于使用。
		gy = g * cosu;
		gx = g * sinu;//延垂直于斜面和平行于斜面分解加速度。
		double h1 = tanu * double(x);//下落点的x所在斜面高度
		h = double(y) - h1;
		d = sqrt(x*x+h1*h1);
		v = sqrt(2 * g*h);
		vx = sinu * v;//平行
		vy = cosu * v;//垂直
		int ans = 0; double cnt = 0;
		while (1)
		{
			if (cnt > d - 1)
				break;
			ans++;
			t = 2 * (vy / gy);
			double dx = vx * t + gx * t*t / 2;
			//以平行于斜面的关系求出其运动的距离。
			vx += gx * t;
			cnt += dx;
		}
		cout << ans << endl;
	}
	return 0;
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值