CF317A.Perfect Pair

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.

Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y).

What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect?

我们称一对整数 mm-完美,如果该对数中至少有一个数大于或等于 mm。因此,数对 (3,3)(3, 3) 和 (0,2)(0, 2) 是 22-完美的,而数对 (−1,1)(-1, 1) 则不是。

黑板上写着两个整数 xx、yy。每次操作允许擦去其中一个数,并将其替换为两数之和 x+yx + y。

要使给定的整数对变为 mm-完美,最少需要执行多少次这样的操作?

输入格式

Single line of the input contains three integers x, y and m ( - 1018 ≤ x, y, m ≤ 1018).

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier.

输入仅包含一行,其中有三个整数 xx、yy 和 mm(−1018≤x,y,m≤1018-10^{18} \le x, y, m \le 10^{18})。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin、cout 流或 %I64d 说明符。

输出格式

Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one.

输出将给定数对转换为 m-完美数对所需的最少操作次数;若无法实现,则输出 "-1"(不带引号)。

输入输出样例

  • 输入#1

    1 2 5

    输出#1

    2
  • 输入#2

    -1 4 15

    输出#2

    4
  • 输入#3

    0 -1 5

    输出#3

    -1

说明/提示

In the first sample the following sequence of operations is suitable: (1, 2) (3, 2) (5, 2).

In the second sample: (-1, 4) (3, 4) (7, 4) (11, 4) (15, 4).

Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations.

在第一个样例中,以下操作序列是可行的:(1, 2) (3, 2) (5, 2)。

在第二个样例中:(-1, 4) (3, 4) (7, 4) (11, 4) (15, 4)。

最后,在第三个样例中,无法使 xx、yy 同时为正数,因此不存在满足条件的操作序列。

输入解题思路,AI测评打分。不知道怎么写?

首页