7WA,求助

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

linmaonan @ 2023-10-18 19:08:56

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,v,t;
    cin>>s>>v;
    if(s%v!=0) t = (s/v)+1;
    else t = s/v;
    t+=10;
    int h=0,m=0;
    if(t>=60)
    {
        h = t/60;
        m = t%60;
    }
    else 
    {
        m = t;
        //h = 8;
    }
    if(h>=8||(h==7&&m>0))
    {
        h-=8;
        h=24-h;
    }
    else h=8-h;
    if(m>0)
    {
        h--;
        m=60-m; 
    }
    //cout<<h<<":"<<m;
    printf("%02d:%02d",h,m);
    return 0;
}

by Leanard @ 2023-10-18 19:32:37

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double num1,num2,c;
    cin>>num1>>num2;
    int s=470;
    c=ceil(num1/num2*1.0);
    s-=c;
    if(s<0)s+=1440;
    if(s/60<10)cout<<0;
    cout<<s/60<<":";
        if(s%60<10)cout<<0;
        cout<<s%60;
    return 0;
}

|