Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <math.h>
- #include <algorithm>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main()
- {
- double n, r;
- cin >> n >> r;
- cout.precision(3);
- cout.setf(ios::fixed);
- if (n / 2.0 >= r)
- cout << M_PI*r*r;
- else
- {
- if (sqrt(n*n + n*n) / 2 < r)
- cout << n*n;
- else
- {
- double a = 2.0*acos((n / 2.0) / r);
- double l = 2.0*r*sin(a / 2.0);
- double S = (a / 2.0)*r*r - (l*n / 2.0) / 2.0;
- cout << (M_PI*r*r) - 4.0 * S;
- }
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment