top1编程
← 返回题目
题解

铲雪车

1 条题解

  • 0
    @ 2026-7-29 0:21:08
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        double dis = 0, time;
        long long h, m, ax, bx, ay, by;
        cin >> ax >> ay;
        while(cin >> ax >> ay >> bx >> by)
            dis += 2*sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));//dis:总距离 单位:米
        time = dis / 1000 / 20;//time:总时间,单位:小时
        h = floor(time);//小时数
        m = round((time - h)*60);//分钟数
        cout << h << ':' << setw(2) << setfill('0') << m;//输出分钟,不足2位时左边补0 
        return 0;
    }
    
    • 1