为什么我#4#7过不了啊?

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

B_hua @ 2023-11-04 14:07:22

#include <stdio.h>
#include <math.h>
int main ()
{
    int n=8*60;
    int t;
    double s,v;
    scanf("%lf%lf",&s,&v);
    if(s>=1&&v<=10000){
        t=ceil(s/v);
        int a,b;
        if(t<(8*60)){
            a=t%60;
            b=t/60;
            printf("%02d:%02d",8-b-1,60-a-10);
        }else if(t>(8*60)&&t<(8*60+24*60)){
            t-=n;
            a=t%60;
            b=t/60;
            printf("%02d:%02d",24-b-1,60-a-10);
        }
    }
    return 0;
}

by littlebug @ 2023-11-04 14:28:48

参考下我的代码?

#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int s,v;
    scanf("%d%d",&s,&v);
    int times=10+ceil(1.0*s/v);
    int fromz=60*(24+8)-times;
    int hh=(fromz/60)%24;
    int mm=fromz%60;
    printf("%02d:%02d\n",hh,mm);
    return 0;
}

by B_hua @ 2023-11-04 14:39:14

@littlebug 谢谢


|