-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10573.cpp
More file actions
47 lines (38 loc) · 1023 Bytes
/
uva-10573.cpp
File metadata and controls
47 lines (38 loc) · 1023 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define PI 2*acos(0.0)
using namespace std;
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int test, i, Len;
double r, r1, r2, t, area;
bool spaceFound;
char input[20];
scanf("%d", &test);
getchar();
while (test--) {
gets(input);
/// If input has any white space(s), then there are r1 and r2, otherwise t
Len = strlen(input);
spaceFound = false;
for (i = 0; i < Len; i++) {
if (input[i] == ' ') {
spaceFound = true;
break;
}
}
if (spaceFound) {
sscanf(input, "%lf%lf", &r1, &r2);
r = r1 + r2;
}
else {
sscanf(input, "%lf", &t);
r = t / 2.0;
r1 = r2 = r / 2.0;
}
area = (PI * r * r) - (PI * r1 * r1) - (PI * r2 * r2);
printf("%.4lf\n", area);
}
return 0;
}