第38579题 单选题
小杨的机器人正在能量踏板上跳跃,踏板编号为 $1, 2, 3, \ldots$。跳到第 $n$ 块踏板的方案数满足递推式 $f(n)$ $= f(n-1) + f(n-2)$。若 $f(1) = 1, f(2) = 2$,则运行以下代码计算 jump(5) 的结果是( )。
int jump(int n) {
if (n <= 2)
return n;
int a = 1, b = 2, c = 0;
for (int i = 3; i <= n; i++) {
c = a + b;
a = b;
b = c;
}
return c;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析