一直都是八十分,#4和#7一直都过不了。

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

dead000 @ 2023-09-22 12:13:07

来个佬救一下救一下

#include<stdio.h>
int main()
{
    int s,v,t,t1,t2;
    scanf("%d %d",&s,&v);
    t=s/v;
    if(s%v!=0){
        t++;
    }
    t1=7-t/60,t2=60-t%60-10;
    if(t1>=0){
        if(t2>=10){
        printf("0%d:%d",t1,t2);
        return 0;}else{
        printf("0%d:0%d",t1,t2);
        return 0;}
    }
    if(t1<0){
        t1=24+t1;
        if(t1<8){
        printf("08:00");
        return 0;
        }
        if(t2>=10){
        printf("%d:%d",t1,t2);
        return 0; }else{
        printf("%d:0%d",t1,t2);
        return 0;    
        }
    }
    return 0; 
}

by HASPID @ 2023-09-22 22:04:07

#include<iostream>
using namespace std;
int main(){
    int s,v,h=8,m,t;
    cin>>s>>v;
    if(s%v==0)t=s/v;
    else if(s%v!=0)t=s/v+1;
      t+=10;
    if(t%60==0)h=h-t/60;
    else h=h-t/60-1;
    if(h<0)h=24+h;
    if(t%60==0)m=0;
    else m=60-t%60;
    if(h<10&&m<10)cout<<0<<h<<":"<<0<<m;
    else if(h>=10&&m<10)cout<<h<<":"<<0<<m;
    else if(h<10&&m>=10)cout<<0<<h<<":"<<m;
    else if(h>=10&&m>=10)cout<<h<<":"<<m;
}

|