[HDOJ5935] Car (precision, math)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.