大佬求助

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

itz_HanQAQ @ 2024-05-24 21:32:17

#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    double s,v;
    int t2,t3,ans1,ans2;
    cin>>s>>v;
    int t=ceil(s/v)+10;
    int t1=480-t;
    if(t1<0){
        t1=abs(t1);
        t2=t1/60;
        t3=t1%60;
        ans1=24-t2-1;
        ans2=60-t3;
    }
    else if(t1==0){
        cout<<"00:00";
        return 0;
    }
    else{
        t2=t1/60;
        t3=t1%60;
        ans1=8-t2-1;
        ans2=60-t3;
    }
    if(ans1<10)cout<<0<<ans1;
    else cout<<ans1;
    cout<<':';
    if(ans2<10)cout<<0<<ans2;
    else cout<<ans2;
    return 0;
}

代码见上 P5707


by 15137106886lez @ 2024-05-30 18:01:52

说实话,你写的不怎么好看 我不会......


|