呆呆的她啊 @ 2023-10-08 23:56:50
最后一个测试点应该类似10000 8 考虑 进1 比如我一开始输出10.60 但是是11.00 然后开if特判 但是哈 你还要明白怎么输出最后两位类似07这样的 15这样的 要好好判断 上我的代码
by 呆呆的她啊 @ 2023-10-08 23:57:21
#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 Orz___zrO @ 2023-10-09 07:39:20
@呆呆的她啊
我的思路:
先计算出从家走到学校所需要的时间长度,再加上垃圾分类所花费的时间,得到上学前需要的总时间。
然后从8:00开始一分钟一分钟地向前模拟,直到时间为0,这样就得到了最晚出发的时间点。
by 呆呆的她啊 @ 2023-10-09 10:17:49
@Orz___zrO @Orz___zrO 思路好哇