fork(1) download
  1. #include <functional>
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <utility>
  5. #include <sstream>
  6. #include <iomanip>
  7. #include <numeric>
  8. #include <cstdlib>
  9. #include <cstring>
  10. #include <climits>
  11. #include <cstring>
  12. #include <vector>
  13. #include <cstdio>
  14. #include <string>
  15. #include <stack>
  16. #include <deque>
  17. #include <queue>
  18. #include <cmath>
  19. #include <map>
  20. #include <set>
  21. //#include <bits/stdc++.h>
  22. //#define pb push_back
  23. //#define pf push_front
  24. //#define ppb pop_back
  25. //#define ppf pop_front
  26. #define lwb lower_bound
  27. #define upb upper_bound
  28. #define X first
  29. #define Y second
  30. //#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
  31. //#define FORV(i, v) FOR(i, 0, ((v).size()))
  32. //#define sz(a) (int)((a).size())
  33. //#define all(a) a.begin() , a.end()
  34. #define coud(a,b) cout<<fixed << setprecision((b)) << (a)
  35. #define L(x) ((x)<<1)
  36. #define R(x) (((x)<<1)+1)
  37. //#define int long long
  38. #define double long double
  39. #define joon ios :: sync_with_stdio(false)
  40. //#define cin fin
  41. //#define cout fout
  42.  
  43. using namespace std;
  44.  
  45. typedef pair<int, int> pii;
  46. typedef long long ll;
  47. const double pi = acos(-1);
  48. const double eps = 1e-7;
  49.  
  50. int main()
  51. {
  52. joon;
  53. cin.tie(0);
  54.  
  55. double a,r;
  56. cin>>a>>r;
  57. double tet=a/(2*r);
  58. tet=asin(tet)*180.0/pi;
  59. tet*=2;
  60. double s=pi*r*r;
  61. s*=tet/360.0;
  62. double r2=r;
  63. r2*=r2;
  64. double bh=a/2.0;
  65. bh*=bh;
  66. r2-=bh;
  67. double oh=(double)sqrt(r2);
  68. oh*=a;
  69. oh/=2.0;
  70. s-=oh;
  71. cout<< fixed << setprecision(12) << s << endl;
  72.  
  73. return 0;
  74. }
  75.  
  76.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
nan