#GOBJ701H. GESP 7级客观题|三角、指数与对数函数|课后作业
GESP 7级客观题|三角、指数与对数函数|课后作业
GESP 7级客观题|三角、指数与对数函数|课后作业
考试频率:高频。本卷共 6 题。
-
使用
math.h或cmath头文件中的对数函数,表达式log(256)的结果类型为double、值约为8.0。{{ select(1) }}
- 正确
- 错误
- 定义变量
double x,如果下面代码输入为100,输出最接近( )。
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
int main(){
double x;
cin >> x;
cout << log10(x) - log2(x) << endl;
cout << endl;
return 0;
}
{{ select(2) }}
0-5-88
-
若变量
x为double类型正数,则log(exp(x)) > log10(x)。( ){{ select(3) }}
- 对
- 错
- 下面程序的输出为()。
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << (int)log(8) << endl;
return 0;
}
{{ select(4) }}
- 2
- 3
- 8
- 无法通过编译。
- 给定一个整数数组
nums,找到其中最长的严格上升子序列的长度。子序列是指从原数组中删除一些元素(或不删除)后,剩余元素保持原有顺序的序列。该程序的时间复杂度为()
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int lengthOfLIS(vector<int> &nums)
{
int n = nums.size();
if (n == 0)
return 0;
vector<int> dp(n, 1);
for (int i = 1; i < n; i++)
{
for (int j = 0; j < i; j++)
{
if (nums[i] > nums[j])
{
_________________________
}
}
}
return *max_element(dp.begin(), dp.end());
}
int main()
{
int n;
cin >> n;
vector<int> nums(n);
for (int i = 0; i < n; i++)
{
cin >> nums[i];
}
int result = lengthOfLIS(nums);
cout << result << endl;
return 0;
}
{{ select(5) }}
-
使⽤
math.h或cmath头⽂件中的对数函数, 表达式log(128)的结果类型为double、 值约为7.0。{{ select(6) }}
- 正确
- 错误