#P1399. Day3.5 STL lower_bound 与 upper_bound(10题)

Day3.5 STL lower_bound 与 upper_bound(10题)

第 1 题

使用 lower_boundupper_bound 前,区间通常必须( )。

{{ select(1) }}

  • 有序
  • 全部相等
  • 长度为偶数
  • 倒序输入且不排序

第 2 题

lower_bound 返回( )。

{{ select(2) }}

  • 第一个大于等于x的位置
  • 第一个大于x的位置
  • 最后一个小于x的位置
  • x出现次数

第 3 题

upper_bound 返回( )。

{{ select(3) }}

  • 第一个大于x的位置
  • 第一个大于等于x的位置
  • 最后一个等于x的位置
  • x出现次数

第 4 题

有序vector为 {1,3,3,5,8}lower_bound(...,3)-a.begin() 等于多少? {{ input(4) }}

第 5 题

有序vector为 {1,3,3,5,8}upper_bound(...,3)-a.begin() 等于多少? {{ input(5) }}

第 6 题

有序vector为 {1,3,3,5,8},数字3出现多少次? {{ input(6) }}

第 7 题

有序vector为 {1,3,3,5,8}lower_bound(...,4)-a.begin() 等于多少? {{ input(7) }}

第 8 题

有序vector为 {1,3,3,5,8}lower_bound(...,9)-a.begin() 等于多少? {{ input(8) }}

第 9 题

求lower_bound返回位置的下标,正确的是( )。

{{ select(9) }}

  • it-a.begin()
  • a.begin()-it
  • *it-a.begin()
  • it+a.begin()

第 10 题

it==a.end(),说明( )。

{{ select(10) }}

  • 不存在大于等于x的元素
  • x一定在第0位
  • vector为空且仅限此情况
  • x出现两次