Help with code, C++

The value of the above table is defined as .

(Note:  represents the greatest integer smaller than . E.g. )

Fluffy’s homework is to find the minimum number of 90° clockwise rotations to maximise the value of the table.

A 90° clockwise rotation looks like the following:

In the above example, the table’s initial value is  while the table’s value after one rotation is .

Help Fluffy with his homework!

Input Format

There are two lines of input.

  • The first line contains two integers  and .

  • The second line contains two integers  and .


Output Format

Output an integer , the minimum number of 90° clockwise rotations needed to maximise the table’s value.

Sample Input

1 2
3 4

Sample Output



After 2 rotations, the table’s value is , which is the maximum possible.

(How do I solve that in C++?)

Hi @aliciatanina18,

This appears to be homework. We want to help you get the information you need, but we also are concerned that just giving you the answer will rob you of the necessary skills you’ll need to develop. If you can describe the things you’ve tried and how they haven’t worked for you, perhaps someone can give you a nudge in the right direction.