求助,第三个测试点过不了

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

TTHermoso @ 2024-07-25 21:48:19

#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d",&a,&b);
    if(a%b==0){
        c=a/b;
    }else{c=a/b+1;}
    if(c>=50){
        int d=(c+10)/60;
        c=(c+10)%60;
        if(c!=0){
            c=60-c;
            if(d>=8) {
            d=31-d;
            }else{d=7-d;}
            if(d<10){
            printf("0");
            }
            printf("%d:",d);
            if(c<10){
                printf("0%d",c);
            }else printf("%d",c);
        }else {
            if(d>=8) {
                d=32-d;
            }else{d=8-d;}
            if(d<10){
                printf("0");
                printf("%d:",d);
            if(c<10){
                printf("0%d",c);
            }else printf("%d",c);
            }
        }
    }else printf("07:%d",50-c);
    return 0;
}

by haimingbei @ 2024-07-25 21:52:04

@TTHermoso

(AC,求关)

代码(细节挺多的,要考虑挺多)

#include<bits/stdc++.h>
using namespace std;
int main(){
    int s,v;
    cin>>s>>v;
    int t=s/v;
    if(s/v>3590)return 0;
    else if(s%v!=0)t++;
    int m=470-t;
    if(m<0){
        m=1440+m;
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    else{
        int h=m/60,minn=m%60;
        if(h<10){
            if(minn<10)cout<<0<<h<<":"<<0<<minn;
            else cout<<0<<h<<":"<<minn;
        }
        else{
            if(minn<10)cout<<h<<":"<<0<<minn;
            else cout<<h<<":"<<minn;
        }
    }
    return 0;
}

by TTHermoso @ 2024-07-25 21:58:50

@haimingbei 求C语言版本


by goIdie @ 2024-07-25 22:03:25

@TTHermoso ,求关

#include<stdio.h>
int main()
{
    int s,v,t;
    int h,m;
    scanf("%d%d",&s,&v);
    t=(s-1)/v+11;
    h=7-t/60,m=60-t%60;
    if(m==60)h++,m=0; 
    if(h<0)h+=24;
    if(h<10)printf("0%d:",h);
    else printf("%d:",h);
    if(m<10)printf("0%d",m);
    else printf("%d",m);
}

|