Codeforces Educational Round#98 A

Luo_Xubo發表於2020-11-21

A

思路:

考慮三種可能:要不要換,換1,換0


程式碼:

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
typedef long long LL;

int test=1;

int main()
{
	scanf("%d",&test);
	while(test--)
	{
		int x,y;
		cin >> x >> y;
		if(abs(x-y)<=1)
		{
			cout << x + y << '\n';
			continue;
		}
		cout << x + y + abs(x-y)-1 << '\n';
	}
	return 0;
}

相關文章