forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10734.cpp
57 lines (55 loc) · 869 Bytes
/
10734.cpp
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
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
double s[100][3], a, b, c;
int num;
void calc(double x, double y, double z)
{
double t;
if (x > y)
{
t = x;
x = y;
y = t;
}
if (y > z)
{
t = y;
y = z;
z = t;
}
if (x > y)
{
t = x;
x = y;
y = t;
}
for (int i = 0; i < num; i++)
{
double t1 = x / s[i][0], t2 = y / s[i][1], t3 = z / s[i][2];
if (fabs(t1 - t2) < 1e-6 && fabs(t2 - t3) < 1e-6)
{
return;
}
}
s[num][0] = x;
s[num][1] = y;
s[num][2] = z;
num++;
double cosxz = (x * x + z * z - y * y) / (2 * x * z);
double mid = sqrt((x * x + (z * z) / 4 - x * z * cosxz));
calc(x, mid, z / 2);
calc(y, mid, z / 2);
}
int main()
{
int t;
scanf("%d", &t);
for (int cases = 1; cases <= t; cases++)
{
printf("Triangle %d: ", cases);
scanf("%lf %lf %lf", &a, &b, &c);
num = 0;
calc(a, b, c);
printf("%d\n", num);
}
}