You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
615 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, x, e, y;
cin >> a >> b >> c >> d >> x >> e >> y;
for (int i = 1; i <= 500; i++)
for (int j = 1; j <= 500; j++)
for (int k = 1; k <= 500; k++)
if (i + j * b == a * k * b && i + j * d == c * k * d) {
for (int u = 1; u <= 500; u++)
if (u * x * k + (u - e) * y * k == (x + y) * j + i) {
cout << u << endl;
exit(0);
}
}
return 0;
}