fork(1) download
  1. #include <iostream>
  2. #define ll long long
  3. #include <cmath>
  4. using namespace std;
  5. bool check_oe(ll int a, ll int c){
  6. if(a<0) a*=(-1);
  7. if(c<0) c*=(-1);
  8. if((a%2==0 and c%2==0) or (a%2==1 and c%2==1)) return false;
  9. return true;
  10. }
  11. int main(){
  12. int t;
  13. cin>>t;
  14. while(t--){
  15. ll int a,b,c;
  16. cin>>a>>b>>c;
  17. if(check_oe(a,c)){
  18. if(b==floor((double)(a+c)/2)) cout<<"1"<<endl;
  19. else if(b<floor((double)(a+c)/2)) cout<<(1+floor((double)(a+c)/2)-b)<<endl;
  20. else cout<<(b-floor((double)(a+c)/2))<<endl;
  21.  
  22. }
  23. else cout<<abs((a+c)/2-b)<<endl;
  24.  
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 4308KB
stdin
Standard input is empty
stdout
Standard output is empty