90分求助

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

Toji @ 2023-10-29 15:29:25

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int s, v;
    cin >> s >> v;
    int time1 = ceil((1.0*s/v) + 11);
    int time2 = 1920 - time1;
    int time3 = time2 % 60;
    int time4 = ((time2 - time3)/60)% 24;

    if (time4 < 10 && time3 < 10)
    {
        cout << "0" << time4 << ":" << "0" << time3;
    }
    if (time4 < 10 && time3 > 10)
    {
        cout << "0" << time4 << ":" << time3;
    }
    if (time4 > 10 && time3 < 10)
    {
        cout<<time4 << ":" << "0" << time3;
    }
    if (time4 > 10 && time3 > 10)
    {
        cout << time4 << ":" << time3;
    }
    return 0;
}

by lan_chance @ 2023-10-29 15:39:47

int类型不要用ceil !!!!!!!!!!


by Toji @ 2023-10-29 16:19:13

大佬,展开说说 (刚刚试着time1换成了double,还是wa。大佬是意思是整形类型不使用ceil进行向上取整吗?)


|