80分,为啥,求大佬教

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

Y1987794678 @ 2023-10-07 17:47:43

代码如下


using namespace std;
int main()
{
    int S,  t, i=0;
    long v;
    scanf("%d %ld", &S, &v);
    if (S % v == 0)
        t = S / v;
    else
        t = S / v + 1;
    while (t >= 60)
    {
        t = t - 60;
        i++;
    }
    i = 7 - i;
    if (i < 0)
        i = i + 24;
    t = 60 - t - 10;
    printf("%02d:%02d", i,t);
    return 0;
}```

by ZjfAKIOI @ 2023-10-07 18:00:02

#include <bits/stdc++.h>
using namespace std;

int main() {
    int s, v;
    cin>>s>>v;
    int t = ceil(s * 1.0 / v);
    t += 10; 
    if(t <= 8 * 60) {
        int h = 8 - t / 60 - 1, m = 60 - t % 60;
        printf("%02d:%02d", h, m);
    } else {
        int h = 24 - (t / 60 - 8) - 1, m = 60 - t % 60;
        printf("%02d:%02d", h, m);
    }
    return 0;
}

可以先参考


by Y1987794678 @ 2023-10-12 20:33:36

问题已解决。


|