头真的大了,70分求指点

P5707 【深基2.例12】上学迟到

Aphasia3517650240 @ 2024-10-27 17:36:53

#include<iostream>
#include<cstdio>
using namespace std;
int main() {
    int s, v, hour, min, need;
    int t = 0;
    cin >> s >> v;
    if (s/v != 0)
        t = s / v + 1;
    else
        t = s / v;
    hour = ((8 * 60) - (t + 10)) / 60;
    need = 60 * 8;
    min = ((8 * 60) - (t + 10)) % 60;

    if (60 * hour + min <= need * 60)
        printf("%02d:%02d", hour, min);
    else
    {
        hour = ((24 * 60) - (60 * hour + min)) / 60;
        min = ((24 * 60) - (60 * hour + min)) % 60;
        printf("%02d:%02d", hour, min);
    }
    return 0;
}

by 绿茶tevi @ 2024-10-28 17:14:02

你没有考虑花费时间大于8小时的情况吧,你的代码我输入490 1是错误的


|