70分求助(;′⌒`)

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

ParkourCat @ 2024-11-18 20:19:19

#include<bits/stdc++.h>
using namespace std;
int main(){
    double t,s,v;
    cin>>s>>v;
    t=ceil(s/v);
    t+=10;
    if(t<=480){
    int h=7;
    int a,b,c=t;
    a=c/60;
    b=c%60;
    a=h-a;
    b=60-b;
    if(b==60){
        b=0;
        a++;
    }
    if(b<10){
        cout<<"0"<<a<<":"<<"0"<<b;
    }
    else{
        cout<<"0"<<a<<":"<<b;
    }
    }
    else{
        t-=480;
        int x=23,y,z,u=t;
        y=u/60;
        z=u%60;
        y=x-y;
        z=60-y;
        if(z==60){
            z=0;
            y++;
        }
        if(y<10){
            cout<<"0"<<y<<":";
            if(z<10){
                cout<<"0"<<z;
            }
            else{
                cout<<z;
            }
        }
        else{
            cout<<y<<":";
            if(z<10){
                cout<<"0"<<z;
            }
            else{
                cout<<z;
            }
        }
    }
    return 0;
}

|