Check if any square ( with one colored cell ) can be divided into two equal parts | Java program to illustrate the above problem ; function to check if it 's possible to divide the square in two equal parts ; if the painted square is linked anyway to the center of the square then it 's not possible ; else yes it 's possible ; Driver code ; initialize the size of the square ; initialize the dimension of the painted square
import java . io . * ; class GFG { static void halfsquare ( int n , int x , int y ) { int half = n / 2 ; if ( ( half == x half == x - 1 ) && ( half == y half == y - 1 ) ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } public static void main ( String [ ] args ) { int n = 100 ; int x = 51 , y = 100 ; halfsquare ( n , x , y ) ; } }