CCC '11 J3 - Sumac Sequences


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Problem type
Allowed languages
C++, Python
Canadian Computing Competition: 2011 Stage 1, Junior #3

In a sumac sequence, \(t_1, t_2, \dots, t_m\) , each term is an integer greater than or equal \(0\) . Also, each term, starting with the third, is the difference of the preceding two terms (that is, \(t_{n+2} = t_n - t_{n+1}\) for \(n \ge 1\) ). The sequence terminates at \(t_m\) if \(t_{m-1} < t_m\) .

For example, if we have \(120\) and \(71\) , then the sumac sequence generated is as follows:

\displaystyle 120, 71, 49, 22, 27. \[\displaystyle 120, 71, 49, 22, 27.\]

This is a sumac sequence of length \(5\) .

Input Specification

The input will be two positive numbers \(t_1\) and \(t_2\) , with \(0 < t_2 < t_1 < 10\,000\) .

Output Specification

The output will be the length of the sumac sequence given by the starting numbers \(t_1\) and \(t_2\) .

Sample Input

120
71

Output for Sample Input

5

Comments

There are no comments at the moment.