【題解】Codeforces 1401A. Distance and Axis

【題目敘述】http://codeforces.com/contest/1401/problem/A

#include <iostream>
using namespace std;
 
int t, n, k;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n >> k;
        if (n < k) cout << k-n << "\n";
        else if ((n-k)%2) cout << 1 << "\n";
        else cout << 0 << "\n";
    }
}
分享本文 Share with friends