#GOBJ701H. GESP 7级客观题|三角、指数与对数函数|课后作业

GESP 7级客观题|三角、指数与对数函数|课后作业

GESP 7级客观题|三角、指数与对数函数|课后作业

考试频率:高频。本卷共 6 题。

  1. 使用 math.hcmath 头文件中的对数函数,表达式 log(256) 的结果类型为 double 、值约为 8.0

    {{ select(1) }}

  • 正确
  • 错误
  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
  • -8
  • 8
  1. 若变量 xdouble 类型正数,则 log(exp(x)) > log10(x) 。( )

    {{ select(3) }}

  1. 下面程序的输出为()。
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    cout << (int)log(8) << endl;
    return 0;
}

{{ select(4) }}

  • 2
  • 3
  • 8
  • 无法通过编译。
  1. 给定一个整数数组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) }}

  • O(n2)O(n^2)
  • O(n)O(n)
  • O(log(n))O(log(n))
  • O(nlog(n))O(n log(n))
  1. 使⽤ math.hcmath 头⽂件中的对数函数, 表达式 log(128) 的结果类型为 double 、 值约为 7.0

    {{ select(6) }}

  • 正确
  • 错误
蜀ICP备2025119001号-1