Advertisement
for-mile

timus1084

Jul 6th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. using namespace std;
  5. double pi=3.14159265359;
  6. int main()
  7. {
  8.     double l,r;
  9.     double s;
  10.     cin>>l>>r;
  11.     if(r<=l/2.)
  12.         s=pi*r*r;
  13.     else
  14.     if(r<=sqrt(2.)*l/2. && r>l/2.)
  15.     {
  16.         double a=asin(l/(2.*r));
  17.         double f=pi-2*a;
  18.         double sect=r*r/2.*(f-sin(f));
  19.         s=pi*r*r-4*sect;
  20.     }
  21.     else
  22.         s=l*l;
  23.     printf("%0.3f",s);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement