30分求调!!!!!!

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

HarrycodingH @ 2024-07-22 13:47:45


#include <bits/stdc++.h>
using namespace std;
int s,v,stime=8*60+24*60,h,n;
int main (){
    cin >> s >> v;
    if(s%v!=0) stime--;
    stime=stime-s/v-10;
    if(stime>=24*60)stime=stime-24*60;
    h=stime/60;
    n=stime%60;
    cout << h << ":";
    if(n==0) cout<< "00";
    else if(n<10) cout << "0" << n;
    else cout<< n;
    return 0;
}

by haimingbei @ 2024-07-22 13:53:37

自己看看吧

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v;
    cin>>s>>v;
    int t=s/v;
    if(s/v>3590)return 0;
    else if(s%v!=0)t++;
    int m=470-t;
    if(m<0){
        m=1440+m;
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    else{
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    return 0;
}

要考虑的细节很多


by HarrycodingH @ 2024-07-22 13:59:06

谢大佬!!☆⌒(*^-゜)v 已关


|