首页 / 客观题库

80380 - CSP-S2024阅读题1

题目(材料题)

 #include <iostream>
using namespace std;
 
const int N = 1000;
int c[N];
 
int logic(int x, int y) {
    return (x & y) ^ ((x ^ y) | (~x & y));
}
 
void generate(int a, int b, int *c) {
    for (int i = 0; i < b; i++)
        c[i] = logic(a, i) % (b + 1);
}
 
void recursion(int depth, int *arr, int size) {
    if (depth <= 0 || size <= 1) return;
    int pivot = arr[0];
    int i = 0, j = size - 1;
    while (i <= j) {
        while (arr[i] < pivot) i++;
        while (arr[j] > pivot) j--;
        if (i <= j) {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
            i++; j--;
        }
    }
    recursion(depth - 1, arr, j + 1);
    recursion(depth - 1, arr + i, size - i);
}
 
int main() {
    int a, b, d;
    cin >> a >> b >> d;
    generate(a, b, c);
    recursion(d, c, b);
    for (int i = 0; i < b; ++i) cout << c[i] << " ";
    cout << endl;
}
 
||

当 $1000≥d≥b $时,输出的序列是有序的。( )

正确

错误

当输入 5 5 1 时,输出为 1 1 5 5 5。( )

正确

错误

假设数组 c  长度无限制,该程序所实现的算法的时间复杂度是 $O(b)$ 的。( )

正确

错误

( 单选 )

函数 int logic(int x, int y) 的功能是( )

A 按位与

B 按位或

C 按位异或

D 以上都不是

( 单选 )

当输入为 10 100 100 时,输出的第 100 个数是?( )

A 91

B 94

C 95

D 98

意见反馈

    最多上传3张图片,格式为JPG、PNG、JPEG,单张不超过5MB

    注册

    发送验证码

    密码必须包含数字、字母和特殊字符

    找回密码

    发送验证码

    密码必须包含数字、字母和特殊字符

    运行 ID:67149

    • 测试点1:Accepted
    • 用时:0 ms
    • 内存:288 kb
    • 测试点2:Accepted
    • 用时:0 ms
    • 内存:288 kb
    输入
    203
    输出
    203

    test

    测评信息

    错误.in文件下载

    错误.out文件下载

    运行 ID:67149

    2019-01-24 15:06:36