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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

hdu 5112 A Curious Matt

發(fā)布時(shí)間:2024/4/17 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdu 5112 A Curious Matt 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題目連接

http://acm.hdu.edu.cn/showproblem.php?pid=5112

?A Curious Matt

Description

There is a curious man called Matt.

One day, Matt's best friend Ted is wandering on the non-negative half of the number line. Matt finds it interesting to know the maximal speed Ted may reach. In order to do so, Matt takes records of Ted’s position. Now Matt has a great deal of records. Please help him to find out the maximal speed Ted may reach, assuming Ted moves with a constant speed between two consecutive records.

Input

The first line contains only one integer $T$, which indicates the number of test cases.

For each test case, the first line contains an integer $N\ ?(2 \leq N \leq 10000)$,indicating the number of records.

Each of the following $N$ lines contains two integers $t_i$ and $x_i$ $(0 \leq t_i, x_i \leq 10^6)$, indicating the time when this record is taken and Ted’s corresponding position. Note that records may be unsorted by time. It’s guaranteed that all ti would be distinct.

Output

For each test case, output a single line “Case #x: y”, where x is the case number (starting from 1), and y is the maximal speed Ted may reach. The result should be rounded to two decimal places.

Sample Input

2
3
2 2
1 1
3 4
3
0 3
1 5
2 0

Sample Output

Case #1: 2.00
Case #2: 5.00

簡(jiǎn)單題,權(quán)當(dāng)練習(xí)一下英文。。

1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<vector> 7 #include<map> 8 using std::max; 9 using std::cin; 10 using std::cout; 11 using std::endl; 12 using std::fabs; 13 using std::sort; 14 using std::pair; 15 using std::vector; 16 #define pb(e) push_back(e) 17 #define sz(c) (int)(c).size() 18 #define mp(a, b) make_pair(a, b) 19 #define all(c) (c).begin(), (c).end() 20 #define iter(c) decltype((c).begin()) 21 #define cls(arr,val) memset(arr,val,sizeof(arr)) 22 #define cpresent(c, e) (find(all(c), (e)) != (c).end()) 23 #define rep(i, n) for (int i = 0; i < (int)(n); i++) 24 #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) 25 const int N = 10010; 26 typedef unsigned long long ull; 27 struct Node { 28 int t, x; 29 bool operator<(const Node &b) const { 30 return t < b.t; 31 } 32 }rec[N]; 33 int main() { 34 #ifdef LOCAL 35 freopen("in.txt", "r", stdin); 36 freopen("out.txt", "w+", stdout); 37 #endif 38 int t, n, k = 1; 39 scanf("%d", &t); 40 while (t--) { 41 double ans = 0.0; 42 scanf("%d", &n); 43 rep(i, n) scanf("%d %d", &rec[i].t, &rec[i].x); 44 sort(rec, rec + n); 45 for (int i = 1; i < n; i++) { 46 ans = max(ans, fabs((double)rec[i].x - rec[i - 1].x) / (rec[i].t - rec[i - 1].t)); 47 } 48 printf("Case #%d: %.2lf\n", k++, ans); 49 } 50 return 0; 51 } View Code

?

轉(zhuǎn)載于:https://www.cnblogs.com/GadyPu/p/4604126.html

總結(jié)

以上是生活随笔為你收集整理的hdu 5112 A Curious Matt的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。