当前位置:   article > 正文

HDU 6373 Pinball 理想状态下,小球在斜面上的运动规律_斜面上小球与另一个小球碰撞次数问题

斜面上小球与另一个小球碰撞次数问题

 

Pinball HDU - 6373

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. 1
  2. 5 1 -5 3

Sample Output

2

题意:

给定一个小球的坐标以及斜面上的一点,求小球在斜面上的碰撞次数。

转换坐标系之后,就变成了一个有水平加速度的平抛?运动? 

如图

最后算次数的时候其实算错了o(* ̄▽ ̄*)o

应该是(T+1)/2 ?

附代码

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5. const int N=1e5;
  6. const double g=9.8;
  7. int main(int argc, const char * argv[]) {
  8. int t;
  9. scanf("%d",&t);
  10. while(t--)
  11. {
  12. double a,b,x,y;
  13. scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
  14. x=-x;
  15. double arc=atan(b/a);
  16. // printf("%f\n",arc);
  17. double pi=g*sin(arc);
  18. double cu=g*cos(arc);
  19. double h=(y-b/a*x)*cos(arc);
  20. double pi_len=x/cos(arc)+h*sin(arc);
  21. double cu_len=h;
  22. // printf("%f %f\n",pi_len,cu_len);
  23. double pi_t=sqrt(2*pi_len/pi);
  24. double cu_t=sqrt(2*cu_len/cu);
  25. //printf("%f %f\n",pi_t,cu_t);
  26. int ans=(pi_t-cu_t)/cu_t;
  27. printf("%d\n",(ans)/2+1);
  28. }
  29. }

对,我按纸上这么算AC不了(;´д`)ゞ

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/451446
推荐阅读
相关标签
  

闽ICP备14008679号