-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleEquations.cpp
59 lines (52 loc) · 1.2 KB
/
simpleEquations.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
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
ifstream fin("simpleEquations.in");
ofstream fout("simpleEquations.out");
void solve()
{
int times = 0;
fin >> times;
for (int i = 1; i <= times; ++i)
{
int A, B, C;
bool ok = false;
fin >> A >> B >> C;
for (int x = -100; x <= 100 && ok == false; ++x)
{
for (int y = x + 1; y <= 100 && ok == false; ++y)
{
int z = A - x - y;
if (x == y || x == z || y == z)
{
continue;
}
else if (x * y * z == B && x * x + y * y + z * z == C)
{
fout << x << " " << y << " " << z << '\n';
ok = true;
break;
}
}
}
if (ok == false)
{
fout << "No solution.\n";
}
}
}
int main()
{
solve();
return 0;
}