Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5935
Test instructions: An old driver is driving, and the speed of the car is not reduced during driving. The traffic policeman recorded the position of the old driver at nn
a point in time, but the time position. It is known that the old driver departs from position 0, and the recorded time points are integers, asking nn
for the minimum time required to go through the first position.
Puzzle: The last part of the journey must be 1 seconds, only by the principle of speed does not fall out of each paragraph passed the smallest integer time can be.
The original card precision, good pit ah.
1#include <bits/stdc++.h>2 using namespacestd;3 4 Const intMAXN =100100;5 Const DoubleEPS = 1e-9;6 intN, A[MAXN];7 8 intMain () {9 //freopen ("in", "R", stdin);Ten intT, _ =1; Onescanf"%d", &T); A while(t--) { -printf"Case #%d:", _++); -scanf"%d", &n); the for(inti =1; I <= N; i++) { -scanf"%d", &a[i]); - } - intRET =1; + Doublev = a[n]-a[n-1]; - for(inti = n1; I >=1; i--) { + intx = a[i]-a[i-1]; A if(x <= v +EPS) { atv =x; -ret++; - } - Else { - DoubleT = (Double(x-eps)/v); -RET + =int(T +1); inv = (Double(x)/int(T +1)); - } to } +cout << ret <<Endl; - } the return 0; *}
[HDOJ5935] Car (precision, math)