-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobotopia.cpp
More file actions
47 lines (40 loc) · 1.24 KB
/
Copy pathrobotopia.cpp
File metadata and controls
47 lines (40 loc) · 1.24 KB
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
/*(NOT FINISHED)https://open.kattis.com/problems/robotopia*/
#include <iostream>
using namespace std;
int main()
{
double leg1, leg2, arm1, arm2, legTotal, armTotal,
determinant, x, y;
int totalDataSets;
cin >> totalDataSets;
for (int i = 0; i < totalDataSets; i++)
{
cin >> leg1 >> arm1 >> leg2 >> arm2 >> legTotal >> armTotal;
determinant = (leg1 * arm2) - (leg2 * arm1);
if (determinant != 0)
{
x = ((legTotal * arm2) - (leg2 * armTotal)) / determinant;
y = ((leg1 * armTotal) - (legTotal * arm1)) / determinant;
if (((x / 1) == static_cast<int>(x)) && ((y / 1) == static_cast<int>(y)))
{
if ((x <= 0) || (y <= 0))
{
cout << "?" << endl;
}
else
{
cout << x << " " << y << endl;
}
}
else
{
cout << "?" << endl;
}
}
else
{
cout << "?" << endl;
}
}
return 0;
}