60分求助

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

yiyang0328 @ 2023-10-28 12:32:10

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v,t,a=0;
    cin>>s>>v;
    if(s%v==0){
        t=s/v;
    } 
    else{
        t=s/v+1;
    }
    while(t>=60){
        t-=60;
        a+=1;
    }
    if(a==7 && t>=50 || a>7){
        a-=7;
        if(24-a>=10){
            cout<<24-a<<":"<<50-t;
            return 0;
        }
        cout<<"0"<<24-a<<":"<<50-t;
        return 0;
    }   
    cout<<"0"<<7-a<<":"<<50-t;
    return 0;
}

|