46 lines
742 B
C++
46 lines
742 B
C++
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
|
||
|
typedef unsigned long long ull;
|
||
|
|
||
|
int main() {
|
||
|
ios::sync_with_stdio(0);
|
||
|
cin.tie(0);
|
||
|
|
||
|
int total = 0;
|
||
|
|
||
|
while (!cin.eof()) {
|
||
|
int ax, ay, bx, by, px, py;
|
||
|
cin.ignore(12);
|
||
|
cin >> ax;
|
||
|
cin.ignore(4);
|
||
|
cin >> ay;
|
||
|
cin.ignore(13);
|
||
|
cin >> bx;
|
||
|
cin.ignore(4);
|
||
|
cin >> by;
|
||
|
cin.ignore(10);
|
||
|
cin >> px;
|
||
|
cin.ignore(4);
|
||
|
cin >> py;
|
||
|
cin.ignore(2);
|
||
|
|
||
|
int smallest = -1;
|
||
|
for (int a = 0; a <= 100; a++) {
|
||
|
for (int b = 0; b <= 100; b++) {
|
||
|
if (ax * a + bx * b == px && ay * a + by * b == py) {
|
||
|
int n = a * 3 + b;
|
||
|
if (smallest == -1 || n < smallest) {
|
||
|
smallest = n;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (smallest != -1) {
|
||
|
total += smallest;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cout << total << '\n';
|
||
|
}
|