Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int a, b, n, m;
- cin >> a >> b >> n >> m;
- int mina = (n - 1) * a + n;
- int maxa = (n + 1) * a + n;
- int minb = (m - 1) * b + m;
- int maxb = (m + 1) * b + m;
- int l = max(mina, minb);
- int r = min(maxa, maxb);
- if (l > r)
- cout << -1;
- else
- cout << l << " " << r;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement