【HDU-6373】解题报告(物理力学,模拟,2018杭电多校第六场)

原始题目

Pinball

  • Time Limit: 2000/1000 MS (Java/Others)
  • Memory Limit: 262144/262144 K (Java/Others)
  • Total Submission(s): 604
  • Accepted Submission(s): 264

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/s^2\).

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

题目大意

  • 给定一个从原点向一个方向延长的斜板,以及初始小球的坐标,重力加速度。求能在斜板上弹跳几次(不考虑能量损失)

解题思路

  • 物理题,把运动分解成沿板方向和垂直于板的方向的分运动,求出沿板子运动的时间\(t1\),垂直于板子运动的(每一次上升/下降)的时间\(t2\)
  • 考虑一下,当$(2n+1)t2 t1 < (2(n+1)+1)t2 $ 时,n即为答案

解题代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <set>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#define INF 0x3f3f3f3f
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define ms(x,a) memset((x),(a),sizeof(a))
using namespace std;
const int maxn=1e5+5;

int n,m,t;
double a,b,x,y;

void solve(){
double alfa=atan(b/a);
double y1=(y-x*tan(alfa))*cos(alfa);
double x1=y*sin(alfa)+x*cos(alfa);
// cout<<y1<<" "<<x1<<endl;
int n=floor(sqrt(x1/y1*a/b));
cout<<(n+1)/2<<endl;
}

int main(){
ios::sync_with_stdio(false);
cin>>t;
while(t--){
cin>>a>>b>>x>>y;
x=-x;
solve();
}
}

收获与反思

  • 分运动看时间比判断,队友想出来的= =。