由所给图可以发现,整数点就可能出现在两条线上,一条是x=y,而另一条是x=y+2。
其中:
X为奇数时,(x,y)=x+y-1;
X为偶数时,(x,y)=x+y;
#include <iostream> using namespace std; int main () { int n; cin>>n; while(n--) { int x, y; cin>>x>>y; if(x==y+2 || x==y) { if(x%2==0) cout<<x+y<<endl; else cout<<x+y-1<<endl; } else cout<<"No Number"<<endl; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。