-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTSETPOJ.cpp
105 lines (93 loc) · 2.46 KB
/
TSETPOJ.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <string>
#include <vector>
using namespace std;
void solve()
{
struct nums
{
int a;
int b;
int c;
int sum() const
{
return a + b + c;
}
bool operator < (const nums &temp) const
{
if (sum() != temp.sum())
{
return sum() < temp.sum();
}
else if (a != temp.a)
{
return a < temp.a;
}
else if (b != temp.b)
{
return b < temp.b;
}
else
{
return c < temp.c;
}
}
};
vector<nums> out;
for (int a = 1; 3 * a <= 25599; ++a)
{
for (int b = a; a + 2 * b <= 25599; ++b)
{
if (a * b == 10000)
{
continue;
}
if ((10000 * (a + b) % (a * b - 10000)) != 0)
{
continue;
}
int c = (10000 * (a + b)) / (a * b - 10000);
if (c >= b)
{
nums temp{a, b, c};
out.push_back(temp);
//cout << (a + b + c) / 100.0 << " = " << a / 100.0 << " + " << b / 100.0 << " + " << c / 100.0 << " = " << a / 100.0 << " * " << b / 100.0 << " * " << c / 100.0 << "\n";
}
}
}
sort(out.begin(), out.end());
//while (true)
//{
double temp1 = -1.0, temp2 = -1.0;
cin >> temp1 >> temp2;
// if (cin.eof() == true || temp1 == -1.0 || temp2 == -1.0)
// {
// break;
// }
int start = round(temp1 * 100), end = round(temp2 * 100);
cout << fixed << setprecision(2);
int size = out.size();
for (int i = 0; i <= size - 1; ++i)
{
int a = out[i].a;
int b = out[i].b;
int c = out[i].c;
if (a + b + c >= start && a + b + c <= end)
{
cout << (a + b + c) / 100.0 << " = " << a / 100.0 << " + " << b / 100.0 << " + " << c / 100.0 << " = " << a / 100.0 << " * " << b / 100.0 << " * " << c / 100.0 << "\n";
}
}
//}
}
int main()
{
solve();
return 0;
}