跳到正文

个人记录

初赛模拟题

zhoujiazheng1约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年8月21日
收录
2026年10月24日
更新
2026年11月13日
篇幅
约 2 分钟

版本

  1. v1当前

阅读程序题

1.

C++
#include<bits/stdc++.h>

using namespace std;

const int N = 1145;

int n, m;
double a[N];

double f(int a, int b){
  if(!b) return 1;
  return 1.0 * f(a, b >> 1) * f(a, b >> 1) * (b & 1 ? a : 1);
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for(int i = 1; i <= n; i++) cin >> a[i];
  while(m--){
    short l, r, x;
    cin >> l >> r;
    a[l] *= f(x, r - l + 1);
    a[r + 1] /= f(x, r - l + 1);
  }
  for(int i = 2; i <= n; i++){
    a[i] = a[i - 1] * a[i];
  }
  while(n--) cout << fixed << setprecision(13) << a[n + 1] << ' ';
  return 0;
}

其中输入的 nn 和 mm 均不超过 10001000,aa 数组中的元素不超过 1010,l≤r≤nl\le r\le n,x≤10x\le 10。

判断题

  • 该代码中如果将 for 循环中的 int 改为 unsigned short,该代码输出不变()
  • 该代码第一个 while 循环是通过差分的思想将 aa 数组的第 ll 位到第 rr 位的所有元素全部乘 xx()
  • 如果将 f 函数中的第一行“if(!b) return 1;”改为 “if(b == 2) return a * a;”运行程序后输出不变()

选择题

  • 该代码最坏时间复杂度为()
    A. O(nlog⁡n)O(n\log n)
    B. O(mlog⁡n)O(m\log n)
    C. O(m)O(m)
    D. O(mn)O(mn)
  • 将主函数的第一行删去,最后运行时间会()考虑宇宙射线的影响。
    A. 不变
    B. 稍小
    C. 稍大
    D. 以上皆有可能

2.

原文