日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

BestCoder22 1003.NPY and shot 解题报告

發布時間:2024/7/19 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BestCoder22 1003.NPY and shot 解题报告 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5144

題目意思:有個人拋物體,已知拋的速度和高度,問可以拋到的最遠距離是多少。即水平距離。

  做的時候是抄公式的,居然過了,幸運幸運............

  

1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring> 5 #include <algorithm> 6 using namespace std; 7 8 const double g = 9.8; 9 10 int main() 11 { 12 int T; 13 double h, v; 14 while (scanf("%d", &T) != EOF) 15 { 16 while (T--) 17 { 18 scanf("%lf%lf", &h, &v); 19 double tmp = sqrt(v*v + 1ll * 2 * g * h); 20 double t = tmp / g; 21 double ans = t * v; 22 printf("%.2lf\n", ans); 23 } 24 } 25 return 0; 26 } View Code

?

  烏冬子做的比較正規,是用三分做的,還有浮點精度控制,值得學習 ^_^ ?(未經他允許就盜他版權,應該不會怪我的......)

  

1 #include <algorithm> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cmath> 5 #include <iostream> 6 #include <map> 7 #include <numeric> 8 #include <vector> 9 10 using namespace std; 11 12 const double EPS = 1e-8; 13 const double PI = acos(-1.0); 14 const double G = 9.8; 15 16 int h, v; 17 18 double F(double ang) 19 { 20 double hv = cos(ang)*v; 21 double vv = sin(ang)*v; 22 double t1 = vv/G; 23 double t2 = sqrt(2*(vv*t1-G*t1*t1/2.0+h)/G); 24 return hv*(t1+t2); 25 } 26 27 int main() 28 { 29 int kase; 30 scanf("%d", &kase); 31 while (kase--) { 32 scanf("%d%d", &h, &v); 33 double l = 0.0, r = PI/2; 34 while (l < r-EPS) { 35 double d = (r-l)/3.0; 36 double ll = l+d; 37 double rr = r-d; 38 if (F(ll) < F(rr)) 39 l = ll; 40 else 41 r = rr; 42 } 43 printf("%.2f\n", F(l)); 44 } 45 return 0; 46 }

?

  

轉載于:https://www.cnblogs.com/windysai/p/4162015.html

總結

以上是生活随笔為你收集整理的BestCoder22 1003.NPY and shot 解题报告的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。