1 / 2

948 - Fibonaccimal Base

948 - Fibonaccimal Base. ★☆☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 948 - Fibonaccimal Base 解題者: 曾一凡 解題日期: 20 10 年3月 11 日 題意: 給定一個正整數 n (n<10 ⁸ ) ,將其從十進位基底, 改為以 Fibonacci 數列為基底 。 例如 17 以十為基底時, 17=1 * 10 + 7 * 10 ⁰,若以 Fibonacci 數列為基底,則

Download Presentation

948 - Fibonaccimal Base

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 948 - Fibonaccimal Base • ★☆☆☆☆ • 題組:Problem Set Archive with Online Judge • 題號:948 - Fibonaccimal Base • 解題者:曾一凡 • 解題日期:2010年3月11日 • 題意:給定一個正整數 n (n<10⁸),將其從十進位基底, 改為以Fibonacci數列為基底。 例如17以十為基底時,17=1*10+7*10⁰,若以 Fibonacci數列為基底,則 17=1*13+0*8+0*5+1*3+0*2+1*1, 所以17₁₀=100101(fib)。(題目上的Fibonacci數列 從1開始)

  2. 題意範例:1010010 99  1000010010 • 解法:先求出前38個Fibonacci數,然後將輸入的數除以最大的Fibonacci數,若等於1則輸出1,然後把輸入的數減去 1*該Fibonacci數,等於0則輸出0,依此類推,把38個Fibonacci數都除完。 • (求出前38個Fibonacci數是因為題目要求的輸入只到100000000) • 解法範例:無 • 討論:無 • 時間複雜度:假設K為資料量,N為資料數值的上限, 則建立Fibonacci 數列的複雜度為O(logN),整體時間為 O(KlogN),若題目以給定N值,則logN為常數,不隨資料量變化,應此本題之複雜度也可視為O(K)

More Related