JOHNYTHEWINNER

World record - Judge

Jan 24th, 2020
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4. #include <math.h>
  5. #include <cmath>
  6.  
  7. int main()
  8. {
  9.     double worldrecord;
  10.     double meters;
  11.     double time;
  12.  
  13.     cin >> worldrecord;
  14.     do
  15.     {
  16.         cin.clear();
  17.         cin >> meters;
  18.     } while (cin.bad() || meters < 0 || meters> 100000);
  19.  
  20.     do
  21.     {
  22.         cin.clear();
  23.         cin >> time;
  24.     } while (cin.bad() || time < 0 || time> 1000);
  25.  
  26.     double speed = 1 / time;
  27.     double slow = floor(meters / 15);
  28.     double newtime = (meters / speed) + (slow * 12.5);
  29.     if (newtime < worldrecord)
  30.     {
  31.         cout << "Yes, he succeeded! The new world record is " << fixed << setprecision(2) << newtime << " seconds." << endl;
  32.     }
  33.     if (newtime >= worldrecord)
  34.     {
  35.         cout << "No, he failed! He was " << fixed << setprecision(2) << (newtime - worldrecord) << " seconds slower." << endl;
  36.     }
  37.  
  38.  
  39.  
  40.     return 0;
  41. }
RAW Paste Data