??TLE?

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

MCprogramming @ 2024-07-03 13:41:01

测试点信息

Accepted
Accepted
Accepted
Time Limit Exceeded.
Time Limit Exceeded.
Time Limit Exceeded.
Time Limit Exceeded.
Time Limit Exceeded.
Time Limit Exceeded.
Time Limit Exceeded.

请问大家,怎么回事

代码

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

int s,v,h=7,m=50,mm;
int main(){
    cin>>s>>v;
    m-=s/v;
    m-=1;
    while (m<=0){
        h-=1;
    }
    if (h<10){
        cout<<0;
    }
    cout<<h<<":";
    if (m<10){
        cout<<0;
    }
    cout<<m;
    return 0;
}

by qw1234321 @ 2024-07-03 13:45:02

@MCprogramming 死循环了。


by Addicted_Game @ 2024-07-03 13:57:47

while (m<=0){ h-=1; }


by MCprogramming @ 2024-07-03 16:39:42

@Flying_hq o


by MCprogramming @ 2024-07-03 16:46:50

@Flying_hq 所以怎么办


by pi3_141592653589 @ 2024-07-05 21:03:21

@MCprogramming 那几行应该是:

while (m < 0)
{
    h -= 1;
    m += 60;
}

另外要判断h小于零的情况。


|