其他分享
首页 > 其他分享> > Codeforces Round #730 (Div. 2)

Codeforces Round #730 (Div. 2)

作者:互联网

A. Exciting Bets
对两个数同时加或者减,求最大gcd,就是abs(a-b),最后就是0,Δ;Δ,2Δ;2Δ,3Δ的情况

代码

int main()
{
	int t;
	cin >>t;
	while (t--) {
		ll a, b;
		cin >> a >> b;
		if (a == b)
			cout << 0 << " " << 0 << endl;
		else if (abs(a - b) == 1)
			cout << 1 << " " << 0 << endl;
		else {
			ll  dif = abs(a - b);
			ll ans = a % dif;
			ans = min(ans, abs(dif - ans));
			cout << dif<< " " << ans << endl;
		}
	}
}

标签:Bets,cout,int,Codeforces,cin,730,Div,gcd
来源: https://www.cnblogs.com/lingshi321/p/14984354.html