Check if it is possible to reach ( x , y ) from origin in exactly Z steps using only plus movements | C ++ program for the above approach ; Function to check if it is possible to reach ( x , y ) from origin in exactly z steps ; Condition if we can 't reach in Z steps ; Driver Code ; Destination point coordinate ; Number of steps allowed ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; void possibleToReach ( int x , int y , int z ) { if ( z < abs ( x ) + abs ( y ) || ( z - abs ( x ) - abs ( y ) ) % 2 ) { cout << " Not ▁ Possible " << endl ; } else cout << " Possible " << endl ; } int main ( ) { int x = 5 , y = 5 ; int z = 11 ; possibleToReach ( x , y , z ) ; return 0 ; }