Codeforces Round #730 (Div. 2)A. Exciting Bets

给两个个数字A,B. 求是否通过同时增加两个数或者同时减少两个数, 得到最大的gcd. 如果能, 需要同时加.减几?

典型的求gcd缺和gcd无关的题, 因为同增加/减少, 所以差值一样, 所以gcd最大就是差值, 因为gcd(0,max(A,B))最大.

然后几步嘛, 就是求比较小的数到差值的倍数的大小, 求余即可.

#include "bits/stdc++.h"
using namespace std;   
// fast read
const auto fr = [](){
    std::ios_base::sync_with_stdio(0); std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(12);
    return 1;
}();
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.first << ", " << p.second << ")"; };
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
// vars:
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vvi = std::vector<vi>;
using vvl = std::vector<vl>;
using pii = std::pair<int,int>;
using pil = std::pair<int,ll>;
using pli = std::pair<ll,int>;
using pll = std::pair<ll,ll>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
// consts
ll M = 0;
// ksm (kuai su mi)
ll ksm(ll a,ll p){ll res=1;while(p){if(p&1){res=res*a%M;}a=a*a%M;p>>=1;}return res;}
ll gcd(ll a, ll b){if(b == 0) return a; return gcd(b, a % b);}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}

int main() { 
    fr; 
    int T;
	cin >> T;
	while (T--)
	{ 
		ll A,B;
		cin >> A >> B;
		if(A > B)
		{
			swap(A, B);
		}
		if(A == B)
		{
			cout << 0 << " " << 0 << endl;
			continue;
		}
		ll C = B - A;
		ll D = min(A % C, C - A % C);
		cout << C << " " << D << endl;
 	}
	
    return 0; 
}