Advertisement
Guest User

Untitled

a guest
Mar 7th, 2013
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. const double EPS = 1e-9;
  6.  
  7. int main() {
  8.   double best_len, pa_len;
  9.   while (scanf("%lf%lf", &best_len, &pa_len) == 2) {
  10.     assert(pa_len >= best_len - EPS);
  11.  
  12.     double k = (pa_len - best_len) / best_len;
  13.     if (k > 1) k = 1;
  14.  
  15.     double res = cos(k * M_PI / 2);
  16.     if (res < 0) res = 0;
  17.    
  18.     printf("%.9lf\n", res);
  19.   }
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement