12333 - Revenge of Fibonacci
来源:互联网 发布:强制竖屏软件 编辑:程序博客网 时间:2024/06/10 10:15
The well-knownFibonacci sequence is defined as following:
F(0)=
F(1) = 1
F(n)=
F(n - 1) + F(n - 2) 任意 n>=2
Here weregard n as the index of the Fibonacci number F(n).
This sequence hasbeen studied since the publication of Fibonacci book Libber Abaci. So far,many properties of this sequence have been introduced.
You had beeninterested in this sequence, while after reading lots of papers about it. Youthink there's no need to research in it anymore because of the lack of itsunrevealed properties. Yesterday, you decided to study some other sequenceslike Lucas sequence instead.
Fibonacci cameinto your dream last night. ``Stupid human beings. Lots of important propertiesof Fibonacci sequence have not been studied by anyone, for example, from theFibonacci number 347746739…''
You woke up andcouldn't remember the whole number except the first few digits Fibonacci toldyou. You decided to write a program to find this number out in order tocontinue your research on Fibonacci sequence.
Input
There are multipletest cases. The first line of input contains a single integer T denotingthe number of test cases ( T<=50000).
For each testcase, there is a single line containing one non-empty string made up of at most40 digits. And there won't be any unnecessary leading zeroes.
Output
For each testcase, output the smallest index of the smallest Fibonacci number whose decimalnotation begins with the given digits. If no Fibonacci number withindex smaller than 100000 satisfy that condition, output `-1' instead -–you think what Fibonacci wants to told you beyond your ability.
Sample Input
15
1
12
123
1234
12345
9
98
987
9876
98765
89
32
51075176167176176176
347746739
5610
Sample Output
Case #1: 0
Case #2: 25
Case #3: 226
Case #4: 1628
Case #5: 49516
Case #6: 15
Case #7: 15
Case #8: 15
Case #9: 43764
Case #10: 49750
Case #11: 10
Case #12: 51
Case #13: -1
Case #14: 1233
Case #15: 22374
- 12333 - Revenge of Fibonacci
- UVa 12333 - Revenge of Fibonacci
- UVA 12333 Revenge of Fibonacci
- uva 12333 Revenge of Fibonacci
- HDU 4099/UVA 12333 Revenge of Fibonacci
- uva 12333 Revenge of Fibonacci code2
- HDU4099 Revenge of Fibonacci
- UVa12333 - Revenge of Fibonacci
- UVA12333--Revenge of Fibonacci
- HDU 4099 Revenge of Fibonacci
- hdu 4099 Revenge of Fibonacci
- HDU 4099 Revenge of Fibonacci
- HDU 4099 Revenge of Fibonacci
- hdu 5018 Revenge of Fibonacci
- HDOJ 5018 Revenge of Fibonacci
- hdoj 5018 Revenge of Fibonacci
- hdu 5018 Revenge of Fibonacci
- hdoj 5018 Revenge of Fibonacci
- 10391 - Compound Words
- 10763 - Foreign Exchange
- [CODEVS 3044] 矩形面积求并
- 10935 - Throwing cards away I
- 12100—Printer Queue
- 12333 - Revenge of Fibonacci
- Eclipse + JLink 编译和调试TQ2440裸机程序【我使用的是win64版本的eclipse】
- 12504 - Updating a Dictionary
- Matrix Chain Multiplication-geeksforgeeks
- nodejs的字符串操作模块
- Android事件处理之处理键盘事件
- OC语言——基本语法和思想
- Ubuntu 14.04安装搜狗输入法
- 单词匹配