3,5,9,10数据点未过求助!!!

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

Eric1012 @ 2024-01-19 22:24:04

#include <bits/stdc++.h>
using namespace std;
int main(){
    int s,v,t=10;
    cin>>s>>v;
    if(v==0) cout<<"07:50";
    else{
        if(s%v==0) t=t+s/v;
        else t=t+s/v+1;
        int ts,tf;
        ts=t/60;
        tf=t-60*ts;
        if(ts<8){
            if(tf>50){
                cout<<"0"<<7-ts<<":0"<<tf;
            }
            else{
                cout<<"0"<<7-ts<<":"<<60-tf;
            }
        }
        else if(ts>=8 and ts<=14){
            ts=ts-8;
            if(tf>50){
                cout<<23-ts<<":0"<<tf;
            }
            else{
                cout<<23-ts<<":"<<60-tf;
            }
        }
        else{
            ts=ts-14;
            if(tf>50){
                cout<<9-ts<<":0"<<tf;
            }
            else{
                cout<<9-ts<<":"<<60-tf;
            }
        }
    }
}

到底怎么才能搞才能让这段代码不是这么发啊烦死了整这么久都不会把它用代码块输出


by Y_QWQ_Y @ 2024-01-19 23:27:38

@Eric1012 有点夸张了吧?

你代码太复杂了看不懂 我太菜了,你看看我的吧

#include<bits/stdc++.h>
using namespace std;
int s, v, a = 8, b = -10;
int main()
{
    scanf ("%d %d", &s, &v);
    int c = s / v;
    if (v * c < s)++ c;
    b -= c;
    while (b < 0)
    {
        b += 60;
        -- a;
    }
    int d = a;
    if (a < 0)d = 24;
    while (a < 0)
    {
        -- d;
        ++ a;
        if (d <= 0)d = 24;
    }
    a = d;
    if (a < 10)printf ("0");
    printf ("%d:", a);
    if (b < 10)printf ("0");
    printf ("%d", b);
    return 0;
}

by smbyj @ 2024-01-26 15:09:38


|