70分求助,已经算了前一天的了

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

yzbzz147268 @ 2024-10-24 13:22:11

#include<bits/stdc++.h> 
using namespace std;
int main(){
    int u,s,n=0,a=8,b=60,z=0;
    cin>>u>>s;
    n=u/s;
    if(u%s>0){
        n=n+1;
    }
    a=a-n/60-1;
    if(a<=0){
        a=24;
        z=1;
    }
    b=b-n%60;
    b=b-10;
    if(b<0){
        a=a-1;
        b=60-abs(b);
    }

    if(a<10){
        if(a<8&&z==1){
            return 0;
        }
        cout<<0<<a<<":";
    }
    else{
        cout<<a<<":";
    }
    if(b<10){
        cout<<0<<b;
    }
    else{
        cout<<b;
    }
    return 0;
}

by mairuisheng @ 2024-10-24 14:01:23

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

|