Advertisement
erfanul007

UVa 10868

Oct 4th, 2021
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define eps             1e-9
  5.  
  6. int main(){
  7.     #ifdef ERFANUL007
  8.         clock_t tStart = clock();
  9.         freopen("input.txt", "r", stdin);
  10.         freopen("output.txt", "w", stdout);
  11.     #endif
  12.  
  13.     double k, l, s, w, g = 9.81, vsq;
  14.  
  15.     while(cin >> k >> l >> s >> w){
  16.         if(k + l + s + w < eps) break;
  17.  
  18.         double dis = max(0.0, s-l);
  19.         vsq = 2.0 * g * s - k * dis * dis / w;
  20.  
  21.         if(vsq < -eps) cout << "Stuck in the air.\n";
  22.         else if(vsq <= 100.0) cout << "James Bond survives.\n";
  23.         else cout << "Killed by the impact.\n";
  24.     }
  25.  
  26.     #ifdef ERFANUL007
  27.         fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  28.     #endif
  29.  
  30.     return 0;
  31. }
  32.  
  33. /*
  34. F = ma
  35. F * s = 0.5 * m * v * v
  36. m * a * s = 0.5 * m * v * v
  37. v * v = 2 * a * s
  38. F * s = 0.5 * k * dl * dl (dl = v)
  39. v * v = k * dl * dl / m
  40. so v * v = 2 * a * s - k * dl * dl
  41. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement