sidakbhatia's blog

By sidakbhatia, history, 3 years ago, In English

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

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By sidakbhatia, history, 4 years ago, In English

Someone please take a look at the above editorial i could not understand the editorial, so please write a detailed answer. (https://atcoder.jp/contests/abc194/tasks/abc194_f)

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it