Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int t, n, x, a, b;
- cin >> t;
- for (int T = 0; T < t; T++) {
- cin >> n >> x >> a >> b;
- int i = 1;
- while (a > 0 && a <= n && b > 0 && b <= n && i <= x) {
- if (a > b&& a < n)
- a++;
- else if (b > a&& b < n)
- b++;
- else if (a > b&& a == n && b > 1)
- b--;
- else if (b > a&& b == n && a > 1)
- a--;
- i++;
- }
- if (a >= b)
- cout << a - b << endl;
- else
- cout << b - a << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement