hdu6373

唉,高中知识忘完了

转载地址:https://blog.csdn.net/lyf04210031/article/details/81516130

Pinball

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


 

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

Recommend

chendu   |   We have carefully selected several similar problems for you:  6373 6372 6371 6370 6369 

Statistic | Submit | Discuss | Note

题意:俩点,一个确定斜面,一个确定小球初始位置,然后小球静止下落,求在斜面上最多可以弹几次。

题解:

通过推导,求出每次位移的比值为1:2:3:······

第一次碰撞后的位移为8*H*sin

算出斜面长度,然后从1到50,直到公式结果大于斜面长度,然后输出。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define MOD 998244353
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
 
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		double a,b,x,y;
		scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
		double jiao=atan(b/a);
		double sinn=sin(jiao);
		double h=y-b*(-x)/a;
		//cout<<jiao<<endl;
		//cout<<sinn<<endl;
		double L=(y-h)/sinn;
		//cout<<L<<endl;
		int ans=0,sum=0;
		for(int i=1;i<=50;i++)
		{
			ans++;
			sum+=i;
			if((double)sum*8.0*h*sinn>L)
			{
				printf("%d\n",ans);
				break;
			}
		}
	}
	return 0;
}
 

猜你喜欢

转载自blog.csdn.net/zezzezzez/article/details/81589171