【題解】Codeforces 1304A. Two Rabbits

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

#include <iostream>
using namespace std;
 
long long t, x, y, a, b;
 
int main() {
    cin >> t;
    while (t--){
        cin >> x >> y >> a >> b;
        if ((y-x) % (a+b) == 0) cout << (y-x) / (a+b) << "\n";
        else cout << "-1\n";
    }
}
分享本文 Share with friends