-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1084.cpp
More file actions
24 lines (24 loc) · 761 Bytes
/
1084.cpp
File metadata and controls
24 lines (24 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <math.h>
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
double n, r;
double pi = 3.141592654;
int main()
{
cin >> n >> r;
if(r <= n / 2)
{
cout << fixed << setprecision(3) << pi * r * r;
return 0;
}
if(r >= n * sqrt(2) / 2)
{
cout << fixed << setprecision(3) << n * n;
return 0;
}
cout << fixed << setprecision(3) << (r * (r * asin(-sqrt(r * r - n * n / 4) / r) + (-sqrt(r * r - n * n / 4) * -sqrt(-(-sqrt(r * r - n * n / 4) - r) * (-sqrt(r * r - n * n / 4) + r))) / r) / 2 -
r * (r * asin(-n / 2 / r) + (-n / 2 * -sqrt(-(-n / 2 - r) * (-n / 2 + r))) / r) / 2 + n / 2 * sqrt(r * r - n * n / 4)) * 4;
return 0;
}