HDU 6373.Pinball -简单的计算几何+物理受力分析 (2018 Multi-University Training Contest 6 1012)

 

6373.Pinball

 

物理受力分析题目。

画的有点丑,通过受力分析,先求出θ角,为arctan(b/a),就是atan(b/a),然后将重力加速度分解为垂直斜面的和平行斜面的,垂直斜面的记为a1,平行斜面的记为a2。

a1=g*sinθ,a2=g*cosθ,然后算出小球到斜面的侧面高度h,以及小球到斜面底部的距离l,小球走h米高度所花费的时间t2为弹一次花费的时间,然后通过ll花费的时间t1为总时间,直接算倍数就是答案。

具体的代码注释。

 

代码:

 1 //1012-6373-几何-物理题目
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<bitset>
 7 #include<cassert>
 8 #include<cctype>
 9 #include<cmath>
10 #include<cstdlib>
11 #include<ctime>
12 #include<deque>
13 #include<iomanip>
14 #include<list>
15 #include<map>
16 #include<queue>
17 #include<set>
18 #include<stack>
19 #include<vector>
20 using namespace std;
21 typedef long long ll;
22 
23 const double PI=acos(-1.0);
24 const double eps=1e-6;
25 const ll mod=1e9+7;
26 const int inf=0x3f3f3f3f;
27 const int maxn=1e5+10;
28 const int maxm=100+10;
29 #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
30 
31 int main()
32 {
33     int t;
34     cin>>t;
35     while(t--){
36         double a,b,x,y;
37         cin>>a>>b>>x>>y;
38         double g=9.8;//重力加速度
39         double sita=atan(b/a);//斜面倾角θ
40         double a1=g*sin(sita);//垂直斜面的加速度
41         double a2=g*cos(sita);//平行斜面的加速度
42         double h=(y+b/a*x)*cos(sita);//斜面高h
43         double l=(y+b/a*x)*sin(sita)+((-1)*x)/cos(sita);//小球到斜面底的距离l
44         double t1=sqrt(2*l/a1);//小球弹一次的时间
45         double t2=sqrt(2*h/a2);//总的时间
46         int ans=1;//开始的算一次
47         ans+=(t1-t2)/t2/2;//去掉开始的
48         cout<<ans<<endl;
49     }
50 }

 

 

 

 

 

我是傻子。

 

posted @ 2018-08-21 13:47  ZERO-  阅读(327)  评论(0编辑  收藏  举报