编程介的小学生 2020-01-12 14:08 采纳率: 20.5%
浏览 411

Fibonacci 数列问题

Problem Description
We know the Fibonacci Sequence

F1=1,F2=1,F3=2,F4=3,F5=5,

...

Fx = Fx-1+Fx-2

We want to know the Mth number which has K consecutive "0" at the end of Fx.

For example,

F15=610

It is the first number which has only one "0" at the end.

F300=222232244629420445529739893461909967206666939096499764990979600.

It is the second number which has two "0" at the end.

Of course, the Fx may be very large if M and K are big. So we only want to know the subscript of Fx (it means the "x" For a given M and K)

Input
Input includes multiple cases.

First line is the number of case x

The next x lines: Each line contains two integer number, K and M, divided by a space.

Output
For each case:

Print a integer number in a line, is the Mth number which has K consecutive 0s at the end of Fx. (You can believe the answer is smaller than 2^31);

Sample Input
3
1 1
2 2
2 5

Sample Output
15
300
900

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!