|Имя входного файла:||iterate2.in|
|Имя выходного файла:||iterate2.out|
|Ограничение по времени:||1 s|
|Ограничение по памяти:||64 megabytes|
Misha has written another program that solves a difficult problem using iterative method. He wants to estimate the number of iterations again.
This method also uses another sequence zi as its part. This sequence is constructed according the following rules. The first number in sequence is a given non-zero real number z0. The subsequent numbers are calculated using formula . The method stops if the value of zi is negative. It is guaranteed there will be neither division by zero nor zero-valued zi before termination condition.
Write a program that evaluates the number of the first negative member of this sequence.
Input file consists of three numbers: A, B (|A|, |B| ≤ 109) and z0. z0 is a real number with no more than 9 digits after decimal point. Also z0 will not have more than 9 significant digits or exceed 105 by its absolute value. A and B are integer numbers.
Write only one integer number n – the minimal n satisfying condition zn<0. If all numbers in the sequence will be positive, display -1.
|1 -2 3||1|
Источник: Petrozavodsk training camp, Summer 2002. Conclusive contest
Автор: Andrew Lopatin, Nick Durov
Обсудить Отправить решение
Версия для печати