结果是70分,错在哪了?

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

ZOECCCCCCCC @ 2023-11-29 00:01:06

#include "stdio.h"
#include "math.h"
int main() {
    int s,v,t;
    int h,m,m1=7*60+50;
    scanf("%d%d",&s,&v);
    t=s/v;
    if(s%v)
        t+=1;
    m1-=t;
    if(fabs(m1)>24*60) {
        m1=fabs(m1);
        m1 %= 24 * 60;
    }
    m=m1%60;
    h=m1/60;
    printf("%02d:%02d",h,m);
    return 0;
}

by ZOECCCCCCCC @ 2023-11-29 11:28:03

已经解决了,如果有疑问,可以来提问



#include<stdio.h>
#include<math.h>

int main() {
    int s, v, h, m, m1;
    scanf("%d%d", &s, &v);
    int t = s / v;
    if (s % v)
        t += 1;
    m1 = 7 * 60 + 50 - t;
    if (m1 < 0)
        m1 += (24 * 60);
    h = m1 / 60;
    m = m1 % 60;
    printf("%02d:%02d", h, m);
    return 0;
}

|