卡70,求帮

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

xiaozydev @ 2024-08-09 14:32:16

看了一下题解,发现是对时间没有处理好,求大佬帮 代码:

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

by lovely_codecat @ 2024-08-09 14:51:07

#include<iostream>
using namespace std;
int main(){
    int s,v,t=0;
    cin>>s>>v;
    if(s%v==0){
        t=s/v+10;
    }else{
        t=s/v+11;
    }
    int limit=32*60;
    limit-=t;
    if(limit>=24*60)limit%=24*60;
    int hl=limit/60;
    int ml=limit%60;
    if(hl<10){
        cout<<0<<hl;
    }else{
        cout<<hl;
    }
    cout<<":";
    if(ml<10){
        cout<<0<<ml;
    }else{
        cout<<ml;
    }
    return 0;
}

先减再判


by lovely_codecat @ 2024-08-09 14:51:16

@xiaozydev


by xiaozydev @ 2024-08-09 21:40:13

@lovely_codecat 谢谢大佬


|