跳到正文

题解

B2066题解

__Cartesian__Tree__约 1 分钟
原文
文章信息与版本

文章信息

发布
2021年7月4日
收录
2025年12月12日
更新
2026年11月18日
篇幅
约 1 分钟
获赞
46
题目
B2066

版本

  1. v1当前

这道题比较简单,按照题目编写程序。

首先,大本营距离每个房顶的距离其实就是 x×x+y×y\sqrt{x \times x + y \times y}。

其次,这个 xx 坐标和 yy 坐标不一定是整数!否则只能得40分。

AC Code:

C++
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    double sum = 0;
    for (int i = 1; i <= n; i++){
        double x, y;//注意是 double 类型
        int p;
        scanf("%lf%lf%d", &x, &y, &p);
        double dis = sqrt(x * x + y * y);
        sum += dis / 50 + p + dis / 50 + p * 0.5;
        //船往返的时间总和
    }
    printf("%d\n", int(ceil(sum)));//向上取整函数
    return 0;
}