Created
September 15, 2018 08:15
-
-
Save completejavascript/fb41a6d81d4a9a01388e7701a3b283fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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