P5707

· · 题解

这道题太难了!!!

这道题解是本蒟蒻的第一篇题解,如有错误请告诉我。

题目思路:用到校时间 08:00 减去上学路上消耗的时间(走路和分类时间总和),就是最迟出发时间。求走路时间:t=s/v ,注意 t 要向上取整!

提示:输出,不足两位时补零,即小时数(或分钟数)小于 10 时,多输出一个 0!! 代码展示:

#include <bits/stdc++.h>
using namespace std;
int s, v, walktime, gotime, gohour, gominute; 
int main(){
    cin >> s >> v;
    walktime = s/v;
    if(s%v!=0)
        walktime++; 
    gotime = (480 + 2880 - 10 - walktime)%1440;
    gohour = gotime/60;
    if(gohour<10)
        cout << 0;
    cout << gohour << ':';
    gominute = gotime%60;
    if(gominute<10)
        cout << 0;
    cout << gominute << endl;
    return 0;
}