#CSP0015. CSP-J 2026 初赛模拟试卷 九

CSP-J 2026 初赛模拟试卷 九


  1. 1983年,我国第一台亿次超级计算机研发成功,成为继美国、日本之后,第三个能独立设计和制造巨型计算机的国家。该计算机的型号是()。 {{ select(1) }}
  • 天河一号
  • 银河一号
  • 神威·太湖之光
  • 曙光星云

  1. 传输控制协议(TCP)是一种面向连接的、可靠的、基于字节流的传输层通信协议。TCP使用确认应答(ACK)机制来确保数据的可靠传输。每当发送方发送一个数据包时,接收方都会返回一个确认应答。TCP建立连接的过程叫作握手。客户端和服务器之间完成连接建立需要通过()次握手,才能确保建立TCP连接。 {{ select(2) }}
  • 1
  • 2
  • 3
  • 4

  1. 计算机高级语言需要通过“翻译程序”翻译成机器语言形式的目标程序,才能被计算机识别和执行。“翻译”有两种方式:“编译”和“解释”。下列()两种语言都是典型的编译型语言。 {{ select(3) }}
  • C++、Python
  • Python、Java
  • Java、MATLAB
  • Pascal、C++

  1. 二进制小数0.1011对应的八进制数是()。 {{ select(4) }}
  • 0.23
  • 0.51
  • 0.54
  • 0.6875

  1. 给学校的公告栏设计一种编码方案,公告中只包含A、B、C、D四个字符,出现频率分别为 20%20\%30%30\%40%40\%10%10\% 。使用哈夫曼编码后,字符()的编码长度一定最短。 {{ select(5) }}
  • A
  • B
  • C
  • D

  1. 扫描仪扫描了一张彩色照片,扫描分辨率为 300dpi300\mathrm{dpi} (每英寸300个像素),照片尺寸为4英寸 ×\times 6英寸。扫描时设置了24位真彩色。在不进行任何压缩的情况下,这张扫描图片的存储容量约为()。 {{ select(6) }}
  • 2.07MB
  • 4.15MB
  • 6.22MB
  • 8.29MB

  1. 在磁盘上建立子目录管理文件,下列描述中,不属于建立子目录的优点的是()。 {{ select(7) }}
  • 便于文件分类管理
  • 加快文件的查找速度
  • 避免文件名冲突
  • 避免文件重复,节省磁盘使用空间

  1. 假设布尔变量 aa 为真, bb 为假, cc 为真,那么表达式 (ab)(c¬b)(a\wedge b)\vee (c\wedge \neg b) 的结果是()。 {{ select(8) }}
  • 无法确定
  • 语法错误

  1. 哈希表长度为10,哈希函数 H(key)=key%10H(key) = key \% 10 ,采用线性探查法解决冲突。插入序列:{12,22,32,42,52}。在插入完成后,查找关键词32时需要探查的次数(包括第一次计算哈希地址的探查)是( )。 {{ select(9) }}
  • 1
  • 2
  • 3
  • 4

  1. 一棵二叉树, 中序遍历的结果为 "abc", 那么这棵二叉树有( )种不同的形态。 {{ select(10) }}
  • 2
  • 3
  • 4
  • 5

  1. 给定数字0、1、3、4、5、9, 每个数字最多用一次, 可能组成( )个4位偶数。 {{ select(11) }}
  • 360
  • 300
  • 192
  • 108

  1. 以下代码的输出是( )。
int a = 5, b = 3, c = 0;
c = a++ + ++b;
cout << a << " " << b << " " << c;

{{ select(12) }}

  • 5 3 8
  • 5 4 8
  • 6 4 9
  • 6 4 10

  1. 定义 f(n)f(n)nn 的各位数字之和, 如: f(123)=1+2+3=6f(123) = 1+2+3=6 。数字根 dr(n)=f(f(f(n)))dr(n) = f(f(\dots f(n)\dots)) (直到结果不会变化为止), 则 dr(2026)dr(2026) 的结果是( )。 {{ select(13) }}
  • 0
  • 1
  • 9
  • 10

  1. 在NOI Linux终端中, 要删除一个名为"old.exe"的文件, 应该使用命令( )。 {{ select(14) }}
  • del old.exe
  • rm old.exe
  • remove old.exe
  • delete old.exe

  1. 以下代码的输出是( )。
const int N = 5;
int arr[N] = {10,20,30,40,50};
int *p = arr;
int sum = 0;
for (int i = 0; i < N; i++){
    sum += (*p)++;
}
cout << sum;

{{ select(15) }}

  • 10
  • 50
  • 60
  • 150

阅读程序(1):

#include <bits/stdc++.h>
#define int long long
using namespace std;
int f(int x) {
    int res = 0;
    while (x) {
        res += x % 10;
        x /= 10;
    }
    return res;
}
int solve1(int x) {
    if (x < 10) return x;
    return solve1(f(x));
}
int solve2(int x) {
    return (x - 1) % 9 + 1;
}
signed main() {
    int n;
    cin >> n;
    cout << solve1(n) << " " << solve2(n) << endl;
    return 0;
}
  1. 输入1234时,输出的结果为11。 {{ select(16) }}
  • 正确
  • 错误

  1. 输入的数为负数时,输出的两个数肯定不一致。 {{ select(17) }}
  • 正确
  • 错误

  1. 将solve1()的内容改成下面的代码,其功能不变。
while (x >= 10) x = f(x);
return x;

{{ select(18) }}

  • 正确
  • 错误

  1. 若输入的n为一个身份证号码(保证没有x),则下列说法中正确的是()。 {{ select(19) }}
  • 数值超过int类型的最大值,产生溢出
  • 数值太大,会导致solve1()函数递归深度过大,进而导致栈溢出
  • 程序可以正常运行,但实际输出结果不对
  • 程序可以正常运行,输出结果也正确

  1. (4分)函数solve1()和solve2()的时间复杂度分别为()。 {{ select(20) }}
  • O(loglogn)O(\log \log n)O(1)O(1)
  • O(logn)O(\log n)O(1)O(1)
  • O(1)O(1)O(loglogn)O(\log \log n)
  • O(1)O(1)O(logn)O(\log n)

阅读程序(2):

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double ERR = 1e-7;
const double CMP_EPS = 1e-12;

int main() {
    double x;
    scanf("%lf", &x); // 保证输入是非负实数
    double left = 0, right = max(1.0, x);
    while (right - left > ERR) {
        double mid = (left + right) / 2;
        double diff = mid * mid - x;
        if (fabs(diff) <= CMP_EPS) {
            left = mid;
            break;
        }
        if (diff < 0) {
            left = mid;
        } else {
            right = mid;
        }
    }
    printf("%.6lf\n", left);
    return 0;
}
  1. 该程序使用二分法求非负整数的算术平方根。 {{ select(21) }}
  • 正确
  • 错误

  1. 将while循环改为 while (right != left),程序也可以正常输出,但结果不够精确。 {{ select(22) }}
  • 正确
  • 错误

  1. 若输入的数为x,则该程序的时间复杂度为 O(logx)O(\log x) 。 {{ select(23) }}
  • 正确
  • 错误

  1. 当输入0.625时,输出的结果是( {{ select(24) }}
  • 0.025000
  • 0.250000
  • 0.790569
  • 0.800569

  1. (4分)ERR的值修改为(),会导致输出结果有误差。 {{ select(25) }}
  • 1e-6
  • 1e-7
  • 1e-8
  • 1e-9

阅读程序(3):

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 21;
ll n, m, S[N][N];

int main() {
    cin >> n >> m; // 保证 n,m 是不大于 20 的正整数
    if (n < m) {
        cout << 0 << endl;
        return 0;
    }
    if (n == m && m == 0) {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 1; i <= n; i++) S[i][1] = 1;
    for (int j = 2; j <= m; j++)
        for (int i = j; i <= n; i++)
            S[i][j] = S[i - 1][j - 1] + j * S[i - 1][j];
    cout << S[n][m] << endl;
    return 0;
}
  1. 若输入 n=5n=5m=3m=3 ,则程序输出结果为26。 {{ select(26) }}
  • 正确
  • 错误

  1. 程序计算将 nn 个不同元素划分成 mm 个无序集合的方案数。 {{ select(27) }}
  • 正确
  • 错误

  1. 若对第22行代码做如下修改,则程序的功能为:计算将 nn 个不同元素划分到不超过 mm 个非空集合的方案总数。
res = 0;
for (int i = 1; i <= m; i++) res += S[n][i];
cout << res << endl;

{{ select(28) }}

  • 正确
  • 错误

  1. (4分)若输入 n=7n=7m=3m=3 ,则程序输出结果为()。 {{ select(29) }}
  • 105
  • 140
  • 301
  • 305

  1. (4分)若将双重循环的内层循环条件 for (int i = j; i <= n; i++) 改为 for (int i = 1; i <= n; i++) ,则程序()。 {{ select(30) }}
  • 结果不变
  • 结果可能错误,因为会计算多余的状态
  • 结果可能错误,因为会计算无效状态(i<j)
  • 运行出错,因为数组访问越界

完善程序(1):

#include <bits/stdc++.h>
using namespace std;
const int MAXC = 10009;
int n, c, w, v, s, f[MAXC];

void bb01(int w, int v) {
    for (①)
        f[j] = max(f[j], ②);
}

int main() {
    cin >> n >> c;
    for (int i = 1; i <= n; i++) {
        cin >> w >> v >> s;
        for (int k = 1; k <= s; ③)
            ④
        if (⑤) bb01(s * w, s * v);
    }
    cout << f[c] << endl;
    return 0;
}
  1. ①处应填( {{ select(31) }}
  • int j = 0; j <= c; j++
  • int j = w; j <= c; j++
  • int j = c; j >= 0; j--
  • int j = c; j >= w; j--

  1. ②处应填( {{ select(32) }}
  • f[j] + v
  • f[j] + w
  • f[j-w] + v
  • f[j-w] + w

  1. ③处应填( {{ select(33) }}
  • k++
  • k *= 2
  • s -= k, k *= 2
  • s -= k, k *= 2

  1. ④处应填( {{ select(34) }}
  • bb01(w, k);
  • bb01(k * w, v);
  • bb01(w, k * v);
  • bb01(k * w, k * v);

  1. ⑤处应填( {{ select(35) }}
  • !s
  • s
  • s < k
  • s <= k

完善程序(2):

#include <iostream>
#include <string>
#define SIZE 209
using namespace std;

void converts(int *a, string s) {
    int i, len = s.size();
    for (i = 0; i < len; i++) a[i] = s[len - i - 1] - '0';
    for (; i < SIZE; i++) a[i] = 0;
}

void div(int *a, int n) {
    for (int i = SIZE - 1, c = 0; i >= 0; i--) {
        c = ①;
        a[i] = c / n;
    }
}

int mod(int *a, int n) {
    int r = 0;
    for (int i = SIZE - 1; i >= 0; i--)
        r = (r * 10 + a[i]) % n;
    return r;
}

void print(int *a) {
    int i;
    for (i = SIZE - 1; i > 0; i--)
        if (a[i] > 0) break;
    for (②) cout << a[i];
    cout << endl;
}

int x[SIZE];

int main() {
    string s;
    int n;
    cin >> s >> n;
    ③
    int r;
    ④
    ⑤
    print(x);
    cout << r << endl;
    return 0;
}
  1. ①处应填( {{ select(36) }}
  • c / n + a[i]
  • c % n + a[i]
  • c / n * 10 + a[i]
  • c % n * 10 + a[i]

  1. ②处应填( {{ select(37) }}
  • i - 1; i >= 0; i--
  • i - 1; i > 0; i--
  • ; i >= 0; i--
  • ; i > 0; i--

  1. ③处应填( {{ select(38) }}
  • converts(x, n);
  • converts(n, x);
  • converts(x, s);
  • converts(s, x);

  1. ④处应填( {{ select(39) }}
  • mod(x, n);
  • div(x, n);
  • r = mod(x, n);
  • r = div(x, n);

  1. ⑤处应填( {{ select(40) }}
  • mod(x, n);
  • div(x, n);
  • r = mod(x, n);
  • r = div(x, n);