COCI '10 Contest 3 #1 Tablica

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type

Perica was always very good at math. His only weak points were addition and division. To help him with that, his teacher presented him with the following problem.

She gave him a 2 by 2 table, containing positive integers A, B, C and D.

\displaystyle \begin{array}{|c|c|}\hline A & B \\\hline C & D \\\hline\end{array}

We say that the value of a table is equal to:

\displaystyle \frac A C + \frac B D

Perica's task is to find the minimum number of 90 degrees clockwise rotations required to maximize the value of a given table.

Result of a single clockwise rotation is shown below.

\displaystyle \begin{array}{|c|c|}\hline 41 & 99 \\\hline 100 & 13 \\\hline\end{array} \Longrightarrow \begin{array}{|c|c|}\hline 100 & 41 \\\hline 13 & 99 \\\hline\end{array}

Input Specification

The first line of input contains two space separated integers, A and B.

The second line of input contains two space separated integers, C and D.

All integers are positive and not greater than 100.

Output Specification

The first and only line of output must contain a single integer, minimum number of clockwise rotations required to maximize the table's value.

Sample Input 1

1 2
3 4

Sample Output 1

2

Sample Input 2

5 9
7 2

Sample Output 2

0

Sample Input 3

41 99
100 13

Sample Output 3

1

Comments

There are no comments at the moment.