Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/fb41a6d81d4a9a01388e7701a3b283fe to your computer and use it in GitHub Desktop.
Save completejavascript/fb41a6d81d4a9a01388e7701a3b283fe to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int CheckValid(int x, int y)
{
if (x >= y && x - y <= 2)
{
if (x%2 == 0 && y%2 == 0) return x + y;
if (x%2 == 1 && y%2 == 1) return x + y -1;
}
return -1;
}
int main()
{
//freopen("input.txt","r", stdin);
int N, x, y;
cin >> N;
for(int tc = 0; tc < N; tc++)
{
cin >> x >> y;
int ch = CheckValid(x,y);
if ( ch == -1) cout << "No Number" << endl;
else cout << ch << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment