Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 9;
- int a[N];
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // freopen("/home/hamoudi/Coding/run.in", "r", stdin);
- freopen("tabs.in", "r", stdin);
- int tt = 1;
- cin >> tt;
- while (tt--) {
- // We have only two available operations
- // 1- Close all tabs to the left of the selected tab.
- // 2- Close all tabs to the right of the selected tab
- // so we if the tab at the beginning or the end of the tabs. we need only one operation otherwise we will use two operations to close left and right the online tab
- int n, k;
- cin >> n >> k;
- if (n == 1) {
- // in this case we have only one tab (contest tab) so we don't need to use any operation
- cout << 0 << endl;
- } else {
- if (k == 1 || k == n) {
- cout << 1 << endl;
- } else {
- cout << 2 << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement