Here you will find solutions of many problems on spoj. If you want solution of some problem which is not listed in blog or have doubt regarding any spoj problem (which i have solved) or any programming concept (data structure) you can mail me @ raj.nishant360@gmail.com

And my humble request to you all that don't copy the code only try to understand the logic and algorithm behind the code. I have started this because if you tried as hard as you can and still can't find any solution to the problem then you can refer to this.
You can read my answer how to start competitive programming CLICK HERE

Wednesday, September 14, 2016

NSTEPS-Number Steps

Number Steps

Given below code is for nsteps spoj or number steps spoj.




#include <bits/stdc++.h>
using namespace std;
int main(){
 int t;
 cin>>t;
 while(t--){
  int x , y;
  cin>>x>>y;
  if(y > x or y < (x - 2) or y == x - 1){
   cout<<"No Number\n";
   continue;
  }
  if( (x&1) && (y&1)){ // ((x&1) is true when x is odd
   cout<<x+y-1<<endl;
   continue;
  }
  cout<<x+y<<endl;
 }
 return 0;
}

1 comment:

Your comment is valuable to us