Is it possible to reach N and M from 1 and 0 respectively as per given condition | C ++ program for the above approach ; Function that find given x and y is possible or not ; Check if x is less than 2 and y is not equal to 0 ; Perform subtraction ; Check if y is divisible by 2 and greater than equal to 0 ; Driver Code ; Given X and Y ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool is_possible ( int x , int y ) { if ( x < 2 && y != 0 ) return false ; y = y - x + 1 ; if ( y % 2 == 0 && y >= 0 ) return true ; else return false ; } int main ( ) { int x = 5 , y = 2 ; if ( is_possible ( x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }