10分求助

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

panrong @ 2023-10-15 10:32:34


#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,s,u;
    cin>>s>>u;
    int c=s/u+s%u+10;
    int d=c/60;
    c=c%60;
    if(d<8){
        b=60-c;
        a=8-d;
    }
    else if(d==8&&c==0){
        cout<<"00:00";
        return 0;
    }
    else {
        d=d-8;
        b=60-c;
        a=24-d;
    }
    if(b==60){
        b=0;
    }
    if(c!=0){
        a=a-1;
    }
    if(a<10) cout<<0;
    cout<<a<<':';
    if(b<10){
      cout<<0;
    }
    cout<<b;
    return 0;
}

|