救我!!!!!!!!!!!!!!!
查看原帖
救我!!!!!!!!!!!!!!!
1356502
baoyijie楼主2024/10/15 20:12
#include <iostream>
#include <cmath>
#include <vector>

struct Point {
    int x;
    int y;
};

double distance(const Point& p1, const Point& p2) {
    return std::sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
}

int main() {
    int M, n, k;
    std::cin >> M >> n >> k;
    std::vector<Point> weapons(M);
    for (int i = 0; i < M; ++i) {
        std::cin >> weapons[i].x >> weapons[i].y;
    }
    std::vector<Point> bombs(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> bombs[i].x >> bombs[i].y;
    }
    int usedBombs = 0;
    int weaponIndex = 0;
    while (weaponIndex < M) {
        bool foundBomb = false;
        for (int bombIndex = 0; bombIndex < n; ++bombIndex) {
            if (distance(weapons[weaponIndex], bombs[bombIndex]) <= k) {
                weaponIndex++;
                foundBomb = true;
                break;
            }
        }
        if (!foundBomb) {
            usedBombs++;
        }
    }
    std::cout << usedBombs << std::endl;
    return 0;
}
2024/10/15 20:12
加载中...