HDU1250 Hat's Fibonacci 大数斐波那契数列
生活随笔
收集整理的這篇文章主要介紹了
HDU1250 Hat's Fibonacci 大数斐波那契数列
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
點擊打開鏈接
Hat's Fibonacci
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12650????Accepted Submission(s): 4253
Problem Description A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.
F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)
Your task is to take a number as input, and print that Fibonacci number.
Input Each line will contain an integers. Process to end of file.
Output For each case, output the result in a line.
Sample Input 100 Sample Output 4203968145672990846840663646Note:No generated Fibonacci number in excess of 2005 digits will be in the test data, ie. F(20) = 66526 has 5 digits.
Author 戴帽子的
Recommend Ignatius.L???|???We have carefully selected several similar problems for you:??1753?1865?1715?1002?2100
解法:
題中要求的數最大可能到兩千多位,直接開二維數組會空間超限,
所以可以用a[ ][ ]存取一個四位,五位…或八位數等,減小數組的大小,
下面以五位數為例,每次算的結果由以前的對10取余改變成對10萬取余,
輸出的時候找到第一位不是0的輸出,以后的都按照%05d輸出
總結
以上是生活随笔為你收集整理的HDU1250 Hat's Fibonacci 大数斐波那契数列的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HDU1102 Constructin
- 下一篇: HDU 1715 大菲波数