forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobotopia.cpp
40 lines (37 loc) · 920 Bytes
/
robotopia.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
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main()
{
int problems;
cin >> problems;
for(int z = 0; z < problems; z++) {
int L1, A1, L2, A2, LT, AT;
cin >> L1 >> A1 >> L2 >> A2 >> LT >> AT;
int solved = 0;
int ones = 0;
int twos = 0;
for(int i = 1; i <= LT / L1 && solved < 2; i++) {
if((LT - (i*L1)) % L2 == 0) {
int robot2s = (LT - (i*L1)) / L2;
if(AT - i*A1 - robot2s*A2 == 0 && robot2s >= 1) {
ones = i;
twos = robot2s;
solved++;
}
}
}
if(solved != 1) {
cout << "?" << endl;
}
else {
cout << ones << " " << twos << endl;
}
}
return 0;
}