50分

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

AAAAA114514AAAAA @ 2024-09-15 16:04:20

#include <bits/stdc++.h>
using namespace std;
int s,v,h=7,m=50; 
int main(){
    cin>>s>>v;
    if(s%v==0){
        h-=(s/v)/60;
        m-=(s/v)%60;
    }
    else{
        h-=(s/v+1)/60;
        m-=(s/v+1)%60;
    }
    printf("%02d:%02d",h,m);
    return 0;
}

by Moco_jof @ 2024-09-15 16:22:57

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    double s,v;
    scanf("%lf%lf",&s,&v);
    int c=ceil(s/v)+10;
    int ji;
    if(c>480) {
        ji=480-c+1440;
    } else {
        ji=480-c;
    }
    int shi=ji/60,fen=ji%60;
    printf("%02d:%02d",shi,fen);
    return 0;
}

by noip_ioi_luck @ 2024-09-15 16:24:41

因为你定的m=50,当(s/v+1)%60>50时m就变成负数了


by AAAAA114514AAAAA @ 2024-09-15 16:46:16

@noip_ioi_luck @Moco_jof 谢谢


|