Help Needed in coding Problem

Revision en1, by sidakbhatia, 2021-09-26 12:22:51

Hey I was recently giving a coding test for a company and this question appeared.

You are given points (0,0) (N,0) (0,M) and (N,M) that form a rectangle. You have a point (x,y) that is within a rectangle or on one of its edges. Now a straight line is drawn passing through (x,y) to cut the rectangle into 2 parts. Find the max possible area of the part whose area is not larger than the other. Also determine if there are multiple ways to cut the rectangle and achieve the maximum.

Input: N M X Y 1<= N,M<= 1E9 0<=X<=N 0<=Y<=M

Output: Print the max possible area followed by 1 if there are multiple ways to cut the rectangle and achieve maximum else print 0

Sample cases: 2 3 1 2 3.00000 0

the line x=1 gives the optimal cut with no other posibilties.

2 4 1 2 4.000000 1

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English sidakbhatia 2021-09-26 12:24:18 8
en2 English sidakbhatia 2021-09-26 12:23:16 4
en1 English sidakbhatia 2021-09-26 12:22:51 823 Initial revision (published)