Advertisement
mickypinata

TOI10: Fortress

Jul 2nd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.     for(int i = 1; i <= 20; ++i){
  7.         int sum, tr;
  8.         scanf("%d", &sum);
  9.         scanf("%d", &tr);
  10.         if(sum % 2 == 0){
  11.             int x = (sum / 2) - tr;
  12.             int r = tr - x;
  13.             if(x >= 0 && r >= 0){
  14.                 cout << r + 1 << "\n";
  15.                 continue;
  16.             }
  17.         }
  18.         cout << 0 << "\n";
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement