60分求助

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

MA_tian @ 2023-09-10 21:56:49

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

rt %%%


by MA_tian @ 2023-09-11 18:36:27

已AC


|