#10过不了,希望得到指教

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

Ibuprofen_Bo @ 2023-10-10 16:06:17

#include <iostream>
using namespace std;
int main()
{
    long long s,v;
    int m,h,t;
    cin>>s>>v;
    t = double(s)/v+10;
    if (double(s)/v+10 - t >0) t+=1;
    if (t>480)
    {
        t -= 480;
        t = 1440 -480-t;
        h = t/60+8;
        m = t%60;
        cout<<(h>10 ? "":"0")<<h<<':'<<(m>=10 ? "":"0")<<m;

    }
    else if (t<480)
    {
        t = 480-t;
        h = t/60;
        m = t%60;
        cout<<'0'<<h<<':'<<(m>=10 ? "":"0")<<m;
    }
    if (-t+1440==480) cout<<"00:00";
    return 0;
}

以上是代码,恳请各位大牛斧正,以解心头之惑。


by CarrotMeow @ 2023-10-10 16:11:37

#include <cstdio>
#include <cmath>

int main() {
    int s, v;
    scanf("%d%d", &s, &v);
    int f = 60 * (24 + 8) - (10 + ceil(double(s) / v));
    int h = (f / 60) % 24;
    int m = f % 60;
    printf("%02d:%02d", h, m);
}

|