Advertisement
Hamoudi30

Problem F

May 14th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 9;
  4. int a[N];
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(nullptr);
  8.     cout.tie(nullptr);
  9. //    freopen("/home/hamoudi/Coding/run.in", "r", stdin);
  10.     freopen("tabs.in", "r", stdin);
  11.     int tt = 1;
  12.     cin >> tt;
  13.     while (tt--) {
  14. //   We have only two available operations
  15. //   1- Close all tabs to the left of the selected tab.
  16. //   2- Close all tabs to the right of the selected tab
  17. //   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
  18.         int n, k;
  19.         cin >> n >> k;
  20.         if (n == 1) {
  21. //            in this case we have only one tab (contest tab) so we don't need to use any operation
  22.             cout << 0 << endl;
  23.         } else {
  24.             if (k == 1 || k == n) {
  25.                 cout << 1 << endl;
  26.             } else {
  27.                 cout << 2 << endl;
  28.             }
  29.         }
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement