Iamtui1010

coinflip

Dec 4th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<vector>
  4.  
  5. #define long long long
  6. #define nln '\n'
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     //freopen("coinflip.inp", "r", stdin);
  13.     long T;
  14.     cin >> T;
  15.     for (long t = 1; t <= T; ++t)
  16.     {
  17.         long G;
  18.         cin >> G;
  19.         for (long g = 1; g <= G; ++g)
  20.         {
  21.             long i, n, q;
  22.             cin >> i >> n >> q;
  23.             if (n == 0)
  24.             {
  25.                 cout << '0' << nln;
  26.                 continue;
  27.             }
  28.             if (n % 2 == 0)
  29.             {
  30.                 cout << n/2 << nln;
  31.             }
  32.             else
  33.             {
  34.                 if (i == 1)
  35.                 {
  36.                     if (q == 1)
  37.                         cout << n/2 << nln;
  38.                     else
  39.                         cout << n/2+1 << nln;
  40.                 }
  41.                 else
  42.                 {
  43.                     if (q == 2)
  44.                         cout << n/2 << nln;
  45.                     else
  46.                         cout << n/2+1 << nln;
  47.                 }
  48.             }
  49.         }
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment