第二十次CCF计算机软件能力认证

本文探讨了CCF计算机软件能力认证中涉及的几何算法问题,包括称检测点查询、风险人群筛查、点亮数字人生和星际旅行四个主题。在二维几何中,分析了判断圆与直线相交的条件,以及计算最短距离的方法,涉及到余弦定理、勾股定理和弧度计算。这些概念和方法同样适用于更高维度的情况。
摘要由CSDN通过智能技术生成

1、称检测点查询

ACwing 3292

#include <iostream>
#include <algorithm>
using namespace std;

typedef pair<int, int> PII;
const int N = 210;

int n, a, b;
PII pos[N];

bool cmp(const PII &a, PII &b) {
   
    if (a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

int dist(int x, int y) {
   
    return (x - a) * (x - a) + (y - b) * (y - b);
}

int main() {
   
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
   
        int x, y; cin >> x >> y;
        pos[i] = {
   dist(x, y), i};
    }
    sort(pos, pos + n, cmp);
    for (int i = 0; i < 3; i++) cout << pos[i].second + 1 << endl;
    return 0;
}

2、风险人群筛查

ACwing 3293

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 1010;

int n, k, t, xl, yl, xr, yr;
int s[N];

bool check(int x, int y) {
   
    if (x >= xl && x <= xr && y >= yl && y <= yr) return true;
    return false;
}

bool get() {
   
    for (int i = k; i <= t; i++)
        if (s[i] - s[i - k] 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值