0分求助

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

bcbgszyzh @ 2023-11-26 20:39:22

#include<bits/stdc++.h>
using namespace std; 
int main(){
    double a,b;
    cin>>a>>b;
    int x=ceil(a/b);
    printf("%d:%d",7-x/60,50-x%60); 
    return 0;
}

by qishifeng0001 @ 2023-11-26 20:45:35

在输出前加: if(x%60>50){

printf("%d:%d",6-x/60,x%60-50);

return 0;

}


by bcbgszyzh @ 2023-11-26 20:46:22

还是 0pts

#include<bits/stdc++.h>
using namespace std; 
int main(){
    double a,b;
    cin>>a>>b;
    //a/b↑ 
    int x=ceil(a/b);
    if(x%60>50){
        printf("%d:%d",6-x/60,x%60-50);
        return 0;
    }
    printf("%d:%d",7-x/60,50-x%60); 
    return 0;
}

by penguin_is_cool @ 2023-11-27 15:43:01

@bcbgszyzh 我没做这道题,但我觉得你些简单了哦。普及-的题不至于这么简单吧(除了P1372)


by outl @ 2023-11-28 08:23:58

是不是还要考虑两点:①题目中有要求输出格式为 HH:MM,分别代表该时间的时和分。必须输出两位,不足前面补 0。②万一是要前一天出发呢?


by bcbgszyzh @ 2023-11-28 20:44:19

@outl

wa 50pts:

#include<bits/stdc++.h>
using namespace std; 
int main(){
    double a,b;
    scanf("%lf%lf",&a,&b);
    //a/b↑ 
    int x=ceil(a/b);
    if(x%60>50){
        if(x%60-50<10){
            printf("0%d:0%d",6-x/60,x%60-50);
            return 0;
        }
        printf("0%d:%d",6-x/60,x%60-50);
        return 0;
    }
    if((50-x%60)<10){
        printf("0%d:0%d",7-x/60,50-x%60); 
        return 0;
    }
    printf("0%d:%d",7-x/60,50-x%60); 
    return 0;
}

by outl @ 2023-11-28 22:50:13

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

by outl @ 2023-11-28 22:51:44

@bcbgszyzh 缺少考虑万一晚上00:00之前就出发的情况


by Dark_Monarch @ 2023-12-03 15:25:50

@bcbgszyzh

#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
    int s,v;
    scanf("%d%d",&s,&v);
    int t_min = ceil(1.0 * s / v) + 10; //向上取整, 分钟为单位 
    int time_sum = 60 * (24 + 8); //时间限制
    int ans = time_sum - t_min;//从0点算,何时出发
    int h = (ans / 60) % 24;
    int min = ans % 60;
    printf("%02d:%02d",h,min);
    return 0;
}

by bcbgszyzh @ 2023-12-03 16:41:21

@ywz121014 ac 程序?


by Dark_Monarch @ 2023-12-04 19:02:11

@bcbgszyzh 发了


|