#12438. 珅泽教育CSP-J第一轮模拟考第二十八套 第 28 题

珅泽教育CSP-J第一轮模拟考第二十八套 第 28 题

二、阅读程序(判断题请选择“正确”或“错误”,共 18 题、40 分)

阅读程序(3)

输入保证 a>0a>0

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
long long k[N];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &k[i]);
    }
    sort(k, k + n);
    while (m--) {
        long long a, b, c;
        scanf("%lld %lld %lld", &a, &b, &c);
        if (c <= 0) {
            printf("NO\n");
            continue;
        }
        int pos1 = lower_bound(k, k + n, b) - k;
        int pos2 = pos1;
        if (pos1 != 0) {
            pos2 = pos1 - 1;
        }
        if (pos1 != n && (b - k[pos1]) * (b - k[pos1]) < 4 * a * c) {
            printf("YES\n%lld\n", k[pos1]);
        } else if (pos2 != n && (b - k[pos2]) * (b - k[pos2]) < 4 * a * c) {
            printf("YES\n%lld\n", k[pos2]);
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

删除第 13 行 sort(k,k+n) 后,程序运行结果不变。( )

{{ select(1) }}

  • 正确
  • 错误