Advertisement
Promi_38

cf 1560B

Sep 30th, 2021
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits\stdc++.h>  
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.    
  10.     while(t--)
  11.     {
  12.         long long a, b, c;
  13.         scanf("%lld %lld %lld", &a, &b, &c);
  14.        
  15.         int n = 2*abs(a-b) ;
  16.         if(a > n || b > n || c > n) printf("-1\n");
  17.         else
  18.         {
  19.             c += n/2;
  20.             while(c > n) c -= n;
  21.             printf("%lld\n", c);
  22.         }
  23.     }
  24.    
  25. }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement