1 条题解

  • 0
    @ 2025-8-24 21:03:10

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar Cartesian__Tree
    May miracles happen, my friend.

    搬运于2025-08-24 21:03:10,当前版本为作者最后更新于2021-07-04 22:14:06,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


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

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

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

    AC Code:

    #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;
    }
    
    • 1

    信息

    ID
    6923
    时间
    1000ms
    内存
    128MiB
    难度
    1
    标签
    递交数
    1
    已通过
    1
    上传者