#10722. 递推与递归第三题(NOIP2014)
递推与递归第三题(NOIP2014)
第三题(NOIP2014)
#include<iostream>
using namespace std;
int fun(int n) {
if (n == 1) return 1;
if (n == 2) return 2;
return fun(n-2) - fun(n-1);
}
int main() {
int n;
cin >> n;
cout << fun(n) << endl;
return 0;
}
- 【判断题】输入114514时,在普通计算机上程序运行时间不会超过1s。
{{ select(1) }}
- 正确
- 错误
- 【判断题】输入0,程序不会出现运行错误。
{{ select(2) }}
- 正确
- 错误
- 【判断题】该程序开启O2优化不会出现错误。
{{ select(3) }}
- 正确
- 错误
- 【判断题】输入6,输出7。
{{ select(4) }}
- 正确
- 错误
- 【选择题】时间复杂度为( )。
{{ select(5) }}
- O(2ⁿ)
- O(nⁿ)
- O(n^logn)
- O(n)
- 【选择题】输入7时输出( )。
{{ select(6) }}
- -11
- 11
- -10
- 10