Check if it is possible to move from ( a , 0 ) to ( b , 0 ) with given jumps | CPP program to move form ( a , 0 ) to ( b , 0 ) with given jumps ; Function to check if it is possible ; Driver code ; function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool Move ( int a , int x , int b ) { if ( ( ( ( b - a ) % x == 0 ) || ( ( b - a - 1 ) % x == 0 ) && a + 1 != b ) && b >= a ) return true ; return false ; } int main ( ) { int a = 3 , x = 2 , b = 7 ; if ( Move ( a , x , b ) ) cout << " Yes " ; else cout << " No " ; }