90分过不了,求指导

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

Dear123 @ 2023-10-10 21:07:32

#include <iostream>
using namespace std;
int main(){
    double s,v;
    cin>>s>>v;
    int t;
    int HH,MM;
    if(s/v!=(int)(s/v)*v) t=s/v+11;
    else t=s/v+10;
    int h1=t/60;
    int m1=t%60;
    if(h1>8) HH=8+24-h1-1;
    else HH=8-h1-1;
    MM=60-m1;
    if(HH<8&&MM>=10) cout<<"0"<<HH<<":"<<MM<<endl;
    else if(HH<8&&MM<10) cout<<"0"<<HH<<":"<<"0"<<MM<<endl;
    else if(HH>=8&&MM<10) cout<<HH<<":"<<"0"<<MM<<endl;
    else cout<<HH<<":"<<MM<<endl;
}

by zhangbochen @ 2023-10-14 17:25:13

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

|