Reduce N to 0 or less by given X and Y operations | C ++ Program to implement the above approach ; Function to check if N can be reduced to <= 0 or not ; Update N to N / 2 + 10 at most X times ; Update N to N - 10 Y times ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool NegEqu ( int N , int X , int Y ) { while ( X -- and N > N / 2 + 10 ) { N = N / 2 + 10 ; } while ( Y -- ) { N = N - 10 ; } if ( N <= 0 ) return true ; return false ; } int main ( ) { int N = 100 ; int X = 3 ; int Y = 4 ; if ( NegEqu ( N , X , Y ) ) { cout << " Yes " ; } else { cout << " No " ; } }