P5707

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

akmAlg @ 2024-12-01 20:20:48

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int s, v;
    cin >> s >> v;

    int tempMin = s / v;
    if (s % v != 0)
    {
        tempMin += 1;
    }
    tempMin += 10;

    int min = 8 * 60 - tempMin;
    int mm, hh;
    if (min < 0)
    {
        min += 24 * 60;
        mm = min % 60;
        hh = (min - mm) / 60;
    }
    else
    {
        mm = min % 60;
        hh = (min - mm) / 60;
    }

    string resHH = to_string(hh);
    if (resHH.length() == 1)
    {
        resHH = "0" + resHH;
    }

    string resMM = to_string(mm);
    if (resMM.length() == 1)
    {
        resMM = "0" + resMM;
    }

    string res = resHH + ":" + resMM;

    string result = res;
    cout << result << endl;
    return 0;
}

by ruize0920 @ 2024-12-18 17:11:58

谢谢大佬


|