• 这个版本的负项优化基本到位了,但写法上不太好,可参考下作业讲解视频中的写法:

        若另 (n < 0)
            # 这里的 n 一定至少等于 -1
            a := 1
            b := 0
            i := -1
            当始 (i >= n)
                F := a - b
                a := b
                b := F
                i := i - 1
            当终

    正项那边使用了序列,也需要优化:一方面题目并不要求生成序列,而序列本身的存储需要额外空间,序列的串接操作很耗时。

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment