90分WA,想请大佬帮助

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

chiyuwang @ 2024-10-19 13:22:14

include<iostream>```cpp


- 
#include<cmath>
using namespace std;
int main()
{
    double s, v;
    int a, b, c,d;
    cin >> s >> v;
    double t;
    t = ceil(s / v) + 10;
    a = 8 * 60+24*60;
    b = a - t;
    if (b >= 24 * 60) b -= 24 * 60;
    c = b % 60;
    d = b / 60;
    if (d > 10) {
        if (c > 10) { cout << d << ":" << c;}
        else { cout << d << ":0" << c; }
    }
    else {
        if (c > 10) { cout << "0"<<d << ":" << c; }
        else { cout << "0" <<d<< ":0" << c; }
    }

}

by Wangxuan123456 @ 2024-10-19 14:13:14

@chiyuwang
判是否加前导0时弄错了(附AC代码):


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    double s, v;
    int a, b, c,d;
    cin >> s >> v;
    double t;
    t = ceil(s / v) + 10;
    a = 8 * 60+24*60;
    b = a - t;
    if (b >= 24 * 60) b -= 24 * 60;
    c = b % 60;
    d = b / 60;
    if (d >= 10) {
        if (c >= 10) { cout << d << ":" << c;}
        else { cout << d << ":0" << c; }
    }
    else {
        if (c >= 10) { cout << "0"<<d << ":" << c; }
        else { cout << "0" <<d<< ":0" << c; }
    }
}

by chiyuwang @ 2024-10-19 15:11:08

@Wangxuan123456 hh,谢谢大佬,我太粗心了


|