最后一个测试点测出来了一点

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

``` #include <iostream> #include <math.h> using namespace std; bool s1 = 0; bool s2 = 0; int main() { double s, v; cin >> s >> v; int g = 0; double c = 0; c = s / v; int h = s / v; //2 1 if (c - h != 0) g = h + 1; else if (c - h == 0 && c != 0) { if (v == 1)g = s; else g = s / v; } int num = 0; g = g + 10; // cout<<g; while (g / 60 > 0) { num++; g = g - 60; } //cout<<g<<endl; // cout << num << endl; if (60 - g < 10) s1 = 1; //cout<<s1; if (num >= 8) { if (24 - (num - 7) < 10)s2 = 1; // cout<<s2<<" "<<num<<endl; num = num - 8; if (60 - g < 10 && s2) cout << "0" << 23 - num << ":" << "0" << 60 - g; else if (s1 && !s2) cout << 23 - num << ":" << "0" << 60 - g; else if (!s1 && !s2) { if (60 - g == 60) { num = num- 1; g = g + 60;cout << 23 - num << ":" << 60 - g<<"0"; } else cout << 23 - num << ":" << 60 - g; } else if (!s1 && s2) { if (60 - g == 60) { num = num -1; g = g + 60; cout << "0" << 23 - num << ":" << 60 - g<<"0"; } else cout << "0" << 23 - num << ":" << 60 - g; } } else if (num < 8) { if (60 - g < 10) { cout << "0" << 7 - num << ":" << "0" << 60 - g; } else { if(60-g==60) { num=num-1;g=g+60;cout << "0" << 7 - num << ":" << 60 - g<<"0";} else cout << "0" << 7 - num << ":" << 60 - g; } } return 0; } ```
by 呆呆的她啊 @ 2023-10-08 23:57:21


@[呆呆的她啊](/user/226167) >**我的思路:** >先计算出从家走到学校所需要的时间长度,再加上垃圾分类所花费的时间,得到上学前需要的总时间。 >然后从8:00开始一分钟一分钟地向前模拟,直到时间为0,这样就得到了最晚出发的时间点。
by Orz___zrO @ 2023-10-09 07:39:20


@[Orz___zrO](/user/1055592) @[Orz___zrO](/user/1055592) 思路好哇
by 呆呆的她啊 @ 2023-10-09 10:17:49


|